Defining a preGoal

Since you would like to incorporate the generated SOAP client into your own project, you need to use the Maven Axis plug-in. When the Axis plug-in generates source, your build needs to make sure that the source it generates is included in your project's compilation. To accomplish this, you need to define a preGoal and postGoal on the java:compile goal.

How do I do that?

The Axis plug-in generates source files and places them in maven.axis.generated.dir, which defaults to target/axis/src. While you don't want to copy the generated source files to your project by copying them to src/main/java, you do want these files to be included in your project's artifact. You need to execute the axis:compile goal before you execute the java:compile goal, as axis:compile will add the source generated by axis:wsdl2java to the compilation source path. The following maven.xml file uses a preGoal which executes another goal before java:compile:

Note

Maven 2 gets rid of preGoal and postGoal. In Maven 2 a build is defined as a series of phases, such as build, compile, and test. Specific goals bind to phases in a project's build lifecycle.

<?xml version="1.0" encoding="UTF-8"?>
  
<project default="jar"
    xmlns:j="jelly:core" 
    xmlns:ant="jelly:ant" 
    xmlns:maven="jelly:maven"
  
<preGoal name="java:compile">
  <attainGoal name="axis:compile" />
</preGoal>
</project>

Executing the java:compile goal produces the following output (some file paths have been truncated):

 __ __ | \/ |_ _ _Apache_ _ _ _ ...

Get Maven: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.