9

默认情况下,maven 编译器插件将编译后的类放入${project.build.directory}/classes. 我想把它们放进${project.build.directory}/myclasses. 该参数-d更改已编译类的目标。我配置了插件,但出现错误: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>
4

2 回答 2

7

你应该可以这样做:

<build>
    <outputDirectory>${project.build.directory}/myclasses</outputDirectory>
</build>
于 2012-06-21T15:59:04.703 回答
6

目标文件夹必须存在。您可以使用 ant 任务创建它:

<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>
于 2012-06-21T16:01:49.883 回答