実行時にCode Generate.javaによって生成されるクラスをコンパイルしようとしています。私はexec-maven-pluginによって実行時にGenerate.javaを正常に実行することができました。これはgenerated-source-javaでコードを生成しています。しかし、このコードはコンパイルされていません。私は同じものを一つのjarファイルに追加したいのですが、maven-assembly-pluginを使っています。
ここにpomスナップショットがあります。実行時に生成されるJavaファイルをコンパイルする方法
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>build-test-environment</id>
<phase>generate-test-resources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.test.Generate</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources-java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>test</finalName>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
私はそれを試して、それは動作していません。私の現在のpomは生成されたコードを.java拡張子でコピーしているのに対し、ターゲット/クラスにコードをコピーすることさえできません。 –
上記の設定と同じ設定を使用しましたが、フェーズのみが変更されましたか?私はすべての既存の設定を再入力しませんでした。はいと仮定すると、次のステップは、デバッグオプション( '-X')を設定してMavenを実行し、コンパイラプラグインがテストソースを探している場所を確認することです。次に、プラグインを設定して、それぞれの宛先がチェーン内の次のソースになるようにします。 – user944849