Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create folder for generated sources in Maven?

I have to generate sources using wsimport and i assume that it should go to /target/generated-sources/wsimport rather than /src/main/java.

The problem is that wsimport needs target folder created before execution and it fails. Can I create that dir first using any maven plugin. I can do it using ant but i prefer to keep it in POM.

like image 420
Eanlr Avatar asked Oct 18 '10 11:10

Eanlr


People also ask

What are generated sources in Maven?

The “maven-source” plugin is used to pack your source code and deploy along with your project. This is extremely useful, for developers who use your deployed project and also want to attach your source code for debugging.

Which option rightly gives the project's source directory in Maven?

Source Directories The Maven property ${project. basedir} defaults to the top level directory of the project, so the build directory defaults to the target directory in project base dir. It also sets the property ${project.


1 Answers

Try using the add source goal of the build helper plugin:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>${basedir}/target/generated/src/wsimport</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>  
like image 89
serg10 Avatar answered Sep 27 '22 21:09

serg10