Maven 2 & 3 differences on dependency:analyze with cycle - maven

Here's the dependency tree I'm using:
[INFO] ------------------------------------------------------------------------
[INFO] Building PA 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # PA ---
[INFO] myTest:PA:jar:0.0.2-SNAPSHOT
[INFO] \- PC:PC:jar:0.0.1-SNAPSHOT:compile
[INFO] \- myTest:PA:jar:0.0.1-SNAPSHOT:compile
As you can see, there's a cycle :
PA > PC > PA
Using maven 2.2.1:
mvn dependency:analyze
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - myTest:PA:jar:0.0.2-SNAPSHOT
[INFO] task-segment: [dependency:analyze]
[INFO] ------------------------------------------------------------------------
...
[INFO] No dependency problems found
Using maven 3.3.3:
mvn dependency:analyze
[INFO] ------------------------------------------------------------------------
[INFO] Building PA 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
[INFO] --- maven-dependency-plugin:2.8:analyze (default-cli) # PA ---
[WARNING] Used undeclared dependencies found:
[WARNING] myTest:PA:jar:0.0.1-SNAPSHOT:compile
The analyze using maven 3 wants me to add PA as a dependency to PA, to itself. Is it possible to have the same behavior as maven 2 using maven 3?

Here's the workaround I'm using to have the same result as Maven 2 using Maven 3:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>
<ignoredDependencie>${project.groupId}:${project.artifactId}::</ignoredDependencie>
</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

Related

maven doesn't package the compiled source files

I have the following in my pom.xml
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The only classes found in the 0.0.1-SNAPSHOT.jar are from
org.springframework.boot.loader package. None of the class files
compiled from my source files is there. Below is the output of maven
install:
INFO] --------------------< com.stocktrader:stock-trader
-------------------- [INFO] Building stock-trader 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar
]--------------------------------- [INFO] [INFO] ---
build-helper-maven-plugin:3.0.0:add-source (default) # stock-trader
--- [INFO] Source directory: C:\Users\kannanj\IdeaProjects\ibkr\src\main\java added. [INFO] [INFO]
--- maven-resources-plugin:3.2.0:resources (default-resources) # stock-trader --- [INFO] Using 'UTF-8' encoding to copy filtered
resources. [INFO] Using 'UTF-8' encoding to copy filtered properties
files. [INFO] Copying 1 resource [INFO] Copying 3 resources [INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) #
stock-trader --- [INFO] Nothing to compile - all classes are up to
date [INFO] [INFO] --- maven-resources-plugin:3.2.0:testResources
(default-testResources) # stock-trader --- [INFO] Using 'UTF-8'
encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to
copy filtered properties files. [INFO] skip non existing
resourceDirectory
C:\Users\kannanj\IdeaProjects\ibkr\src\test\resources [INFO] [INFO]
--- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) # stock-trader --- [INFO] Nothing to compile - all classes are up to
date [INFO] [INFO] --- maven-surefire-plugin:2.22.2:test
(default-test) # stock-trader --- [INFO] Tests are skipped. [INFO]
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) # stock-trader ---
[INFO] Building jar:
C:\Users\kannanj\IdeaProjects\ibkr\target\stock-trader-0.0.1-SNAPSHOT.jar
[INFO] [INFO] --- spring-boot-maven-plugin:2.7.0:repackage
(repackage) # stock-trader --- [INFO] Replacing main artifact with
repackaged archive [INFO] [INFO] ---
maven-install-plugin:2.5.2:install (default-install) # stock-trader
--- [INFO] Installing C:\Users\kannanj\IdeaProjects\ibkr\target\stock-trader-0.0.1-SNAPSHOT.jar
to
C:\Users\kannanj.m2\repository\com\stocktrader\stock-trader\0.0.1-SNAPSHOT\stock-trader-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\kannanj\IdeaProjects\ibkr\pom.xml to
C:\Users\kannanj.m2\repository\com\stocktrader\stock-trader\0.0.1-SNAPSHOT\stock-trader-0.0.1-SNAPSHOT.pom
[INFO]
------------------------------------------------------------------------ [INFO] BUILD SUCCESS
Please help before I shoot myself.
If you want to use some common parts in another project there are two possible solutions.
First make a multi module build and separate the common from the other parts. The commons part will be a simple jar (also possible with some spring support)
Create a complete separate standalone project and consume that.

setup maven for jdk10

[INFO] Scanning for projects...
[INFO] ---------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] test.master
[INFO] test.generator
[INFO] test.model
[INFO] test.dal
[INFO] test.service
[INFO] test.web
[INFO]
[INFO] ---------------------------------------------
[INFO] Building test.master 0.0.1-SNAPSHOT
[INFO] ---------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # test.master ---
[INFO]
[INFO] --- maven-jdeps-plugin:3.1.1:jdkinternals (default) # test.master ---
[INFO]
[INFO] --- maven-jdeps-plugin:3.1.1:test-jdkinternals (default) # test.master ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # test.master ---
[INFO] Installing C:\Users\cora_kwok\git\backend2\pom.xml to C:\Users\cora_kwok\.m2\repository\com\kinetix\test.master\0.0.1-SNAPSHOT\test.master-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ----------------------------------------------------------
[INFO] Building test.generator 1.0.0
[INFO] -------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # test.generator ---
[INFO] Deleting C:\Users\cora_kwok\git\backend2\test.generator\target
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) # test.generator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\cora_kwok\git\backend2\test.generator\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # test.generator ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\cora_kwok\git\backend2\test.generator\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] -----------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] test.master ............................. SUCCESS [ 0.703 s]
[INFO] test.generator ............................ FAILURE [ 0.790 s]
[INFO] test.model ......................................... SKIPPED
[INFO] test.dal ........................................... SKIPPED
[INFO] test.service ....................................... SKIPPED
[INFO] test.web ........................................... SKIPPED
[INFO] ---------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------------------------------------
[INFO] Total time: 1.715 s
[INFO] Finished at: 2018-05-09T14:14:05+08:00
[INFO] Final Memory: 11M/40M
[INFO] ---------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test.generator: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :test.generator
Below is my pom.xml for the module test.generator . I would like to use jdeps to check the 3rd party dependency of jdk10, and prepare for the jdk10 upgrade, however, when I try to run and results the above errors.
I did remove my m2.repository folder, but the same error still exists.
I have installed the jdk10 and jre10. However, it seems it failed to recognize jdk10 during the maven build.
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.kinetix</groupId>
<artifactId>test.master</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.kinetix.test</groupId>
<artifactId>test.generator</artifactId>
<version>1.0.0</version>
<name>test.generator</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>10.0.1</java-version>
</properties>
<dependencies>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I have no idea why it failed to recognize jdk10 for version 10.0.1 is smaller than that of version 1.7.
You have to define the maven-compiler plugin via pluginManagement like this:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
</plugins>
</pluginManagement>
..
</build>
Furthermore you should define the property like this:
<properties>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
<maven.compiler.release>10</maven.compiler.release>
</properties>
You have multi module build where you have a parent where you should define the above. Furthermore I recommend strongly to define all plugins you are using like maven-resources-plugin etc. like the maven-compiler-plugin above...and with most recent versions and not with such ancient versions...

Maven is not downloading a plugin : jetspeed-unpack-maven-plugin

so I made this pom :
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.mssb.ocr</groupId>
<artifactId>tesseractOcr</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<!-- autorun unit tests during maven compilation -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<argLine>-Xmx1024m -XX:MaxPermSize=256m -XX:-UseSplitVerifier</argLine>
<skipTests>-DskipTests</skipTests>
</configuration>
</plugin>
<!--
this extract the 32 bits dll and the tesseractdata folder to
the project root from tess4j.jar
-->
<plugin>
<groupId>org.apache.portals.jetspeed-2</groupId>
<artifactId>jetspeed-unpack-maven-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<unpack>
<artifact>net.sourceforge.tess4j:tess4j:jar</artifact>
<overwrite>true</overwrite>
<resources combine.children="append">
<resource>
<path>win32-x86</path>
<destination>${basedir}</destination>
<overwrite>true</overwrite>
<flat>true</flat>
<include>*</include>
</resource>
<resource>
<path>tessdata</path>
<destination>${basedir}</destination>
<overwrite>true</overwrite>
<flat>false</flat>
<include>*</include>
</resource>
</resources>
</unpack>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--
Log4j 2 is broken up in an API and an implementation (core), where the API
provides the interface that applications should code to. Strictly speaking
Log4j core is only needed at runtime and not at compile time.
However, below we list Log4j core as a compile time dependency to improve
the startup time for custom plugins.
-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.1</version>
</dependency>
<!--
Integration of tesseract OCR
-->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
mvn clean install and eclipse:eclipse both end up in a "SUCCESS" however the jeetspeed plugin does nothing, I don't see him doing anything in the console when building and he his not even in my local repository.
Yes, I added maven central to my maven conf file (http://repo1.maven.org/maven2/)
I'm using maven 3.2.1
What could I do?
Thanks
EDIT
mvn clean install
D:\!2015 repo\TTsXXJava>mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] capcha solver
[INFO] tesseract ocr project
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building capcha solver 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # parent ---
[INFO] Deleting D:\!2015 repo\TTsXXJava\target
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # parent ---
[INFO] Installing D:\!2015 repo\TTsXXJava\pom.xml to d:\.m2\fr\mssb\capcha\parent\1.0\parent-1.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building tesseract ocr project 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # tesseractOcr ---
[INFO] Deleting D:\!2015 repo\TTsXXJava\capcha-solver\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # tesseractOcr ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # tesseractOcr ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\!2015 repo\TTsXXJava\capcha-solver\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # tesseractOcr ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # tesseractOcr ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # tesseractOcr ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # tesseractOcr ---
[INFO] Building jar: D:\!2015 repo\TTsXXJava\capcha-solver\target\tesseractOcr-1.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # tesseractOcr ---
[INFO] Installing D:\!2015 repo\TTsXXJava\capcha-solver\target\tesseractOcr-1.0.jar to d:\.m2\fr\mssb\capcha\tesseractOcr\1.0\tesseractOcr-1.0.jar
[INFO] Installing D:\!2015 repo\TTsXXJava\capcha-solver\pom.xml to d:\.m2\fr\mssb\capcha\tesseractOcr\1.0\tesseractOcr-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] capcha solver ..................................... SUCCESS [ 0.381 s]
[INFO] tesseract ocr project ............................. SUCCESS [ 1.910 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.424 s
[INFO] Finished at: 2015-02-05T12:52:22+01:00
[INFO] Final Memory: 14M/231M
[INFO] ------------------------------------------------------------------------
mvn eclipse:eclipse
$ mvn eclipse:eclipse
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] capcha solver
[INFO] tesseract ocr project
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building capcha solver 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-eclipse-plugin:2.5.1:eclipse (default-cli) # parent >>>
[INFO]
[INFO] <<< maven-eclipse-plugin:2.5.1:eclipse (default-cli) # parent <<<
[INFO]
[INFO] --- maven-eclipse-plugin:2.5.1:eclipse (default-cli) # parent ---
[INFO] Not running eclipse plugin goal for pom project
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building tesseract ocr project 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-eclipse-plugin:2.5.1:eclipse (default-cli) # tesseractOcr >>>
[INFO]
[INFO] <<< maven-eclipse-plugin:2.5.1:eclipse (default-cli) # tesseractOcr <<<
[INFO]
[INFO] --- maven-eclipse-plugin:2.5.1:eclipse (default-cli) # tesseractOcr ---
[INFO] Using as WTP server : null
[INFO] Using source status cache: D:\!2015 repo\TTsXXJava\target\mvn-eclipse-cache.properties
[INFO] File D:\!2015 repo\TTsXXJava\capcha-solver\.project already exists.
Additional settings will be preserved, run mvn eclipse:clean if you want old settings to be removed.
[INFO] Wrote Eclipse project for "tesseractOcr" to D:\!2015 repo\TTsXXJava\capcha-solver.
[INFO]
Javadoc for some artifacts is not available.
List of artifacts without a javadoc archive:
o com.sun.jna:jna:3.0.9
o net.java.dev.jai-imageio:jai-imageio-core-standalone:1.2-pre-dr-b04-2011-07-04
o log4j:log4j:1.2.15
o commons-io:commons-io:1.3.1
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] capcha solver ..................................... SUCCESS [ 0.962 s]
[INFO] tesseract ocr project ............................. SUCCESS [ 0.406 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.698 s
[INFO] Finished at: 2015-02-05T12:42:36+01:00
[INFO] Final Memory: 7M/183M
[INFO] ------------------------------------------------------------------------
Parent pom in case you need it (I remove the parent reference in the originaly posted pom)
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.mssb.capcha</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>capcha solver</name>
<modules>
<module>capcha-solver</module>
</modules>
<build>
<plugins>
<!-- All project will be interpreted (source) and compiled (target) in java 7 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- this will make eclipse:eclipse goal work and make the project Eclipse compatible -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7</classpathContainer>
</classpathContainers>
<additionalBuildcommands>
<buildcommand>net.sf.eclipsecs.core.CheckstyleBuilder</buildcommand>
</additionalBuildcommands>
<additionalProjectnatures>
<projectnature>net.sf.eclipsecs.core.CheckstyleNature</projectnature>
</additionalProjectnatures>
</configuration>
</plugin>
</plugins>
</build>
</project>
It is not doing anything because you have not bound any execution of the plugin to a lifecycle phase. You need to add a block like this:
<plugin>
<executions>
<execution>
<id>unpack-step</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
...
</configuration>
</executions>
</plugin>
See http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference for the possible lifecycle phases you can use.

2 exec-maven-plugin defined in POM - not working

I have two Java main classes that I need executed during different parts of a build process. One needs to execute ALWAYS as part of my standard build process during the generate-sources phase. The other needs to execute as part of a profile, but that profile should be execute at the end of the process-classes phase, which should also include the generate-sources phase prior to that.
I was able to get the first plugin working correctly during the generate-sources phase of the standard build process:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.MySourceGenerator</mainClass>
</configuration>
</plugin>
However when I added a second instance of the same plugin to the profile, the plugin defined as part of the standard build is no longer invoked during my build process, resulting in compile errors. This is the configuration in the profile:
<profiles>
<profile>
<id>initSchema</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.SomeOtherClass</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
This is what I run on the command line: mvn process-classes -PinitSchema. What is wrong with my configuration? I am expecting both plugins to execute during their respective phases.
To clarify: the first exec-maven-plugin generates sources and the second one initialized my DB schema.
EDIT:
Here is the output
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ABC Web Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) # web-app ---
[INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/msg added.
[INFO]
[INFO] --- maven-processor-plugin:2.0.6:process (process) # web-app ---
[INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt added
[INFO] javac option: -cp
...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: com.company.vocab.generator.VocabAnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
[INFO] javac option: -s
[INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.2.0.Final
[INFO] diagnostic /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/AccountDto.java:5: error: cannot find symbol
import com.telos.xacta.util.Messages;
...
(more similar messages)
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (default) # web-app ---
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] compiling a schema...
...
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # web-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 16 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # web-app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 281 source files to /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
[INFO] -------------------------------------------------------------
...
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/ProjectHeadDto.java:[4,28] cannot find symbol
symbol: class Messages
location: package com.company.util
...
(more similar errors)
...
[INFO] 29 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.817s
[INFO] Finished at: Thu Aug 01 20:49:07 EDT 2013
[INFO] Final Memory: 31M/282M
[INFO] ------------------------------------------------------------------------
Give both the execution blocks a different id, because now they both use the default id and so one will overwrite the other.

maven-invoker doesn't call install on dependency

i have a problem in my maven build process. there is a pom file which uses the maven-invoker-plugin to execute different tasks:
<execution>
<id>createWebstartApps</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<projectsDirectory>.</projectsDirectory>
<streamLogs>true</streamLogs>
<pomIncludes>
<pomInclude>pom1.xml</pomInclude>
</pomIncludes>
....
but when i use the maven release plugin "mvn release:prepare" the install goal will not be executed on the child pom dependencies. For example the pom1.xml has the following dependency:
<dependency>
<groupId>com.qnamic.dis</groupId>
<artifactId>DisAdminToolWithPlugins</artifactId>
<version>${project.parent.version}</version>
<type>pom</type>
<scope>runtime</scope>
.....
But this dependency (in this case the pom file) will not be installed in my local maven repo and therefore not be found:
[INFO] [INFO] Building: pomWebstartDisAdminTool.xml
[INFO] [INFO] [INFO] Scanning for projects...
[INFO] [INFO] [INFO]
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [INFO] Building RailOpt DIS Admin Tool 4.9.12
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [WARNING] The POM for com.qnamic.dis:DisAdminToolWithPlugins:pom:4.9.12 is missing, no dependency information available
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [INFO] BUILD FAILURE
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [INFO] Total time: 0.203s
[INFO] [INFO] [INFO] Finished at: Tue Feb 05 13:00:04 CET 2013
[INFO] [INFO] [INFO] Final Memory: 4M/15M
[INFO] [INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [ERROR] Failed to execute goal on project DisAdminToolWebstart: Could not resolve dependencies for project com.qnamic.dis:DisAdminToolWebstart:pom:4.9.12: Failure to find com.qnamic.dis:DisAdminToolWithPlugins:pom:4.9.12 in http://maven.ad.bls.ch/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of bls-public has elapsed or updates are forced -> [Help 1]
any ideas?
regards
Try adding install before run. Eg.
<execution>
<id>createWebstartApps</id>
<phase>process-resources</phase>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
...
For more information: http://maven.apache.org/plugins/maven-invoker-plugin/install-mojo.html & http://maven.apache.org/plugins/maven-invoker-plugin/usage.html
HTH,
Jamie
Add the file invoker.properties next to your pom.xml
and put your goals into it, like:
invoker.goals = clean install

Resources