ho questo struttura del progetto:accumulo helper-maven-plugin errore add-test-risorsa
/src
/main
/java
/resources
/test
/java
/resources
/it
/java
/resources
test
per i test unitari e it
per test di integrazione. Sto usando build-helper-maven-plugin per aggiungere ulteriori risorse/risorse di test al classpath per un uso successivo maven-surfire-plugin per l'esecuzione unit tests
e maven-failsafe-plugin per integration tests
.
Plugin config come belows:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-integration-test-resources</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<directory>/src/it/resources</directory>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Questo funziona bene per il test-sources
(sono coppied correttamente a/target/test-classi), ma non copia test-risorse. Ho provato diverse combinazioni di <configuration>
: utilizzare <resource>
invece <directory>
, utilizzare un file specifico invece di una directory ... ma nessuno dei due funziona.
Stacktrace con l'errore:
Caused by: org.apache.maven.plugin.PluginConfigurationException: Unable to parse configuration of mojo org.codehaus.mojo:build-helper-maven-plugin:1.9.1:add-test-resource for parameter directory: Cannot configure instance of org.apache.maven.model.Resource from src/it/resources
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:597)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:529)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
PROVVISORIAMENTE, ho risolto aggiungendo le risorse test di integrazione per Maven <build>
configurazione:
<build>
...
<testResources>
<testResource>
<directory>src/it/resources</directory>
</testResource>
</testResources>
</build>
Ma io preferirei avere accentrato tutto Modifiche al classpath sotto build-helper-maven-plugin
. Qualcuno può pubblicare un esempio con una configurazione corretta?
Grazie in anticipo.
Doh! Hai ragione, è stato uno stupido errore. Grazie mille! – troig