Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-compiler-plugin how to change the classes destination directory

Tags:

maven

By default the maven compiler plugin put the compiled classes into ${project.build.directory}/classes. I want to put them into ${project.build.directory}/myclasses. The argument -d changes the destination of the compiled classes. I configured the plugin but I got an error: javac: directory not found: C:\home\target/myclasses.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <source>1.5</source>
        <target>1.5</target>
        <showDeprecation>true</showDeprecation>
        <compilerArguments>
            <d>${project.build.directory}/myclasses</d>
        </compilerArguments>
    </configuration>
</plugin>
like image 239
Sydney Avatar asked Jun 21 '12 15:06

Sydney


2 Answers

You should be able to do it like this:

<build>
    <outputDirectory>${project.build.directory}/myclasses</outputDirectory>
</build>
like image 83
Sean Patrick Floyd Avatar answered Sep 29 '22 16:09

Sean Patrick Floyd


The destination folder must exists. You can create it using a ant task:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <id>createClassesDir</id>
            <phase>process-resources</phase>
            <configuration>
                <tasks>
                    <mkdir dir="${project.build.directory}/myclasses" />
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
like image 45
Sydney Avatar answered Sep 29 '22 16:09

Sydney