I'm currently using java annotation processing to generate a lot of code (20 seconds), when I run mvn process-resources it will trigger apt only once however when I use mvn package, mvn jetty:run or mvn gwt:run apt been triggered again after war been packaged. Is there a way to force apt only run once?
I have a profile in my pom.xml
<profile>
<id>codegen</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<exists>src/main/resources/META-INF</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.regulationworks.core.code-gen</groupId>
<artifactId>executor</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.5</version>
<executions>
<execution>
<id>generate-jpa-metamodel</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
<outputDirectory>${project.build.directory}/generated-sources/metamodel</outputDirectory>
</configuration>
</execution>
<execution>
<id>generate-gwt-jpa-proxies</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.hibernate.gwtmodelgen.GwtProxyModelEntityProcessor</processor>
</processors>
<outputDirectory>${project.build.directory}/generated-sources/entity-proxies</outputDirectory>
</configuration>
</execution>
<execution>
<id>code-gen-executor</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>com.regulationworks.core.gwt.codegen.CodeGenExecutor</processor>
</processors>
<options>
<generateRequestFactory>${core.codegen.requestfactory}</generateRequestFactory>
<generateMappingXml>${core.codegen.xmlmapping}</generateMappingXml>
<codegen.scaffold>${codegen.scaffold}</codegen.scaffold>
<codegen.scaffold.override>${codegen.scaffold.override}</codegen.scaffold.override>
<codegen.scaffold.classes>${codegen.scaffold.classes}</codegen.scaffold.classes>
<codegen.commands.class.name>${codegen.commands.class.name}</codegen.commands.class.name>
</options>
</configuration>
</execution>
<!--<execution>
<id>generate-gwt-rf</id>
<goals>
<goal>process</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<processors>
<processor>com.google.web.bindery.requestfactory.apt.RfValidator</processor>
</processors>
<options>
<rootOverride>${core.codegen.rfvalidate}</rootOverride>
</options>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
</configuration>
</execution>-->
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>process-classes</phase>
<configuration>
<id>VerifyRequestFactoryInterfaces</id>
<executable>java</executable>
<arguments>
<argument>-cp</argument>
<classpath />
<argument>com.google.web.bindery.requestfactory.apt.ValidationTool</argument>
<argument>${project.build.outputDirectory}</argument>
<argument>${core.codegen.rfvalidate}</argument>
</arguments>
<skip>${core.codegen.rfvalidate}</skip>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
and maven-source-plugin been configured to 'jar-no-fork' (this helped to remove one time when run normal mvn install)
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
here is output in console when run "mvn clean package gwt:run"
X:\workspace\Decision\decision-app>mvn clean package gwt:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DecisionWorks App 2.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.opensaml:opensaml:jar:1.1b is missing, no dependency information available
[WARNING] The POM for net.sf.saxon:saxon-dom:jar:8.9 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # decision-app ---
[INFO] Deleting X:\workspace\Decision\decision-app\target
[INFO]
***********************************************************
This is where apt executed first time which look right
***********************************************************
[INFO] --- maven-processor-plugin:2.0.5:process (generate-jpa-metamodel) # decision-app ---
[INFO] Source directory: X:\workspace\Decision\decision-app\target\generated-sources\metamodel added
[INFO] javac option: -cp
[INFO] javac option: ...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: X:\workspace\Decision\decision-app\target\classes
[INFO] javac option: -s
[INFO] javac option: X:\workspace\Decision\decision-app\target\generated-sources\metamodel
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.0.0.Final
[INFO]
[INFO] --- maven-processor-plugin:2.0.5:process (generate-gwt-jpa-proxies) # decision-app ---
[INFO] Source directory: X:\workspace\Decision\decision-app\target\generated-sources\entity-proxies added
[INFO] javac option: -cp
[INFO] javac option: ...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: org.hibernate.gwtmodelgen.GwtProxyModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: X:\workspace\Decision\decision-app\target\classes
[INFO] javac option: -s
[INFO] javac option: X:\workspace\Decision\decision-app\target\generated-sources\entity-proxies
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 3.7.0-SNAPSHOT
[INFO]
[INFO] --- maven-processor-plugin:2.0.5:process (code-gen-executor) # decision-app ---
[INFO] Source directory: X:\workspace\Decision\decision-app\target\generated-sources\apt added
[INFO] Adding compiler arg: -Acodegen.scaffold.override=true
[INFO] javac option: -cp
[INFO] javac option: ...
[INFO] javac option: -proc:only
[INFO] javac option: -Acodegen.scaffold.override=true
[INFO] javac option: -processor
[INFO] javac option: com.regulationworks.core.gwt.codegen.CodeGenExecutor
[INFO] javac option: -d
[INFO] javac option: X:\workspace\Decision\decision-app\target\classes
[INFO] javac option: -s
[INFO] javac option: X:\workspace\Decision\decision-app\target\generated-sources\apt
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # decision-app ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO] Copying 17 resources
[INFO] Copying 80 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # decision-app ---
[INFO] Compiling 260 source files to X:\workspace\Decision\decision-app\target\classes
[INFO]
[INFO] --- exec-maven-plugin:1.2:exec (default) # decision-app ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # decision-app ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 3 resources
[INFO] Copying 10 resources
[INFO] Copying 17 resources
[INFO] Copying 80 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # decision-app ---
[INFO] Compiling 3 source files to X:\workspace\Decision\decision-app\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.9:test (default-test) # decision-app ---
[INFO] Surefire report directory: X:\workspace\Decision\decision-app\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.172 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) # decision-app ---
[INFO] Packaging webapp
[INFO] Assembling webapp [decision-app] in [X:\workspace\Decision\decision-app\target\decision]
[INFO] Processing war project
[INFO] Copying webapp webResources [X:\workspace\Decision\decision-app\target] to [X:\workspace\Decision\decision-app\target\decision]
[INFO] Copying webapp webResources [X:\workspace\Decision\decision-app\src/main/webapp/WEB-INF] to [X:\workspace\Decision\decision-app\target\decision]
[INFO] Copying webapp resources [X:\workspace\Decision\decision-app\src\main\webapp]
[INFO] Processing overlay [ id com.regulationworks.core:document-cmis-plugin-config]
[INFO] Webapp assembled in [10118 msecs]
[INFO] Building war: X:\workspace\Decision\decision-app\target\decision.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
[INFO]
[INFO] --- maven-source-plugin:2.1.2:jar-no-fork (default) # decision-app ---
[INFO]
[INFO] >>> gwt-maven-plugin:2.3.0:run (default-cli) # decision-app >>>
***********************************************************
This is where apt executed second time which is a waste of time
***********************************************************
[INFO]
[INFO] --- maven-processor-plugin:2.0.5:process (generate-jpa-metamodel) # decision-app ---
[INFO] Source directory: X:\workspace\Decision\decision-app\target\generated-sources\metamodel added
[INFO] javac option: -cp
[INFO] javac option: ...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: X:\workspace\Decision\decision-app\target\classes
[INFO] javac option: -s
[INFO] javac option: X:\workspace\Decision\decision-app\target\generated-sources\metamodel
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.0.0.Final
[INFO]
[INFO] --- maven-processor-plugin:2.0.5:process (generate-gwt-jpa-proxies) # decision-app ---
[INFO] Source directory: X:\workspace\Decision\decision-app\target\generated-sources\entity-proxies added
[INFO] javac option: -cp
[INFO] javac option: ...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: org.hibernate.gwtmodelgen.GwtProxyModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: X:\workspace\Decision\decision-app\target\classes
[INFO] javac option: -s
[INFO] javac option: X:\workspace\Decision\decision-app\target\generated-sources\entity-proxies
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 3.7.0-SNAPSHOT
[INFO]
[INFO] --- maven-processor-plugin:2.0.5:process (code-gen-executor) # decision-app ---
[INFO] Source directory: X:\workspace\Decision\decision-app\target\generated-sources\apt added
[INFO] Adding compiler arg: -Acodegen.scaffold.override=true
[INFO] javac option: -cp
[INFO] javac option: ...
[INFO] javac option: -proc:only
[INFO] javac option: -Acodegen.scaffold.override=true
[INFO] javac option: -processor
[INFO] javac option: com.regulationworks.core.gwt.codegen.CodeGenExecutor
[INFO] javac option: -d
[INFO] javac option: X:\workspace\Decision\decision-app\target\classes
[INFO] javac option: -s
[INFO] javac option: X:\workspace\Decision\decision-app\target\generated-sources\apt
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # decision-app ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO] Copying 17 resources
[INFO] Copying 80 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # decision-app ---
[INFO] Compiling 60 source files to X:\workspace\Decision\decision-app\target\classes
[INFO]
[INFO] --- exec-maven-plugin:1.2:exec (default) # decision-app ---
[INFO]
[INFO] <<< gwt-maven-plugin:2.3.0:run (default-cli) # decision-app <<<
[INFO]
[INFO] --- gwt-maven-plugin:2.3.0:run (default-cli) # decision-app ---
***********************************************************
finally be able to start the web app, 30 seconds wasted for second apt execution
***********************************************************
----------------------- solution -----------------------
add a "package" profile
<profile>
<id>package</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/lib/*-sources.jar, WEB-INF/lib/gwt-user-*.jar</packagingExcludes>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF</directory>
<targetPath>WEB-INF</targetPath>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
<executions>
<execution>
<id>explode-war</id>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
use "mvn clean gwt:run -Ppackage" instead of "mvn clean package gwt:run"
The command you executed is mvn clean package gwt:run. Maven executes the clean lifecycle (clean:clean goal by default). Then it executes package, which runs all goals bound to the package phase and all goals bound to previous phases (generate-sources, process-sources, process-resources, etc.). Finally, it executes the gwt:run goal. If you look at the documentation for the run goal there is one very important line:
Invokes the execution of the lifecycle phase process-classes prior to executing itself.
This means that Maven will run all goals bound to the process-classes phase and all earlier phases again. The apt plugin executions are bound to the generate-sources phase so they repeat, as do resources:resources, compiler:compile, and exec:exec as they are all bound to process-classes or before.
With that in mind: does mvn clean gwt:run work? I know that mvn clean jetty:run works as I expect without duplicating executions, but I've not used gwt before.
Related
Running $mvn clean install works when I'm running from the folder containing the pom but when I go up a folder level and run the same command, I get the following error:
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xsdtools 4.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # xsdtools ---
[INFO] Deleting /home/myUser/Development/gitRepo/xxx_project/project/xsdtoolFolder/target
[INFO]
[INFO] --- maven-enforcer-plugin:1.1:enforce (enforce-versions) # xsdtools ---
[INFO]
[INFO] --- jaxb2-maven-plugin:2.1:xjc (xjc) # xsdtools ---
[INFO] Adding 'extension' flag to XJC arguments, since the 'generateEpisode' argument is given. (XJCs 'episode' argument requires that the 'extension' argument is provided).
[INFO] Ignored given or default xjbSources [/home/myUser/Development/gitRepo/xxx_project/project/xsdtoolFolder/src/main/xjb], since it is not an existent file or directory.
[ERROR] null [-1,-1]
java.io.FileNotFoundException: /home/myUser/Development/gitRepo/xxx_project/project/src/main/xsd/MyProjectV3.xsd (No such file or directory)
at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:232)
The pom file has the following:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The package of your generated sources -->
<sources>
<source>src/main/xsd/MyProjectV3.xsd</source>
</sources>
</configuration>
</plugin>
</plugins>
</build>
and my file structure is
xxx_project
|
-pom.xml
-project
|
-pom.xml
-src
|
-main
|
-xsd
|
-MyProjectV3.xsd
How do I make the build successful regardless of the directory I'm running from?
I have a project which generates java classes with jaxb from xsd schema.
the pom contains
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<!-- The package of your generated sources -->
<packageName>com.melexis.mfgdil.b2mml</packageName>
<sources>
<source>src/main/schema/AllSchemas.xsd</source>
</sources>
</configuration>
</plugin>
When I type mvn clean install the java sources are generated from the
xsd files into target/generated-sources/jaxb, compiled and end up in target/classes, great!
When I dare to immediately run mvn install again, without changing anything, I see :
[INFO] --- jaxb2-maven-plugin:2.2:xjc (xjc) # b2mml ---
[INFO] Ignored given or default xjbSources
[/home/pti/Projects/b2mml/src/main/xjb], since it is not an existent file or directory.
[INFO] No changes detected in schema or binding files - skipping JAXB
generation.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # b2mml ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # b2mml ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/pti/Projects/b2mml/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # b2mml ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/pti/Projects/b2mml/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) #
b2mml ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
the target/classes folder is wiped and all classes from the target/generated-sources are gone and only the single class from the single java source file in my src/main/java tree is left.
I do not get why maven detects changes, and I get even less that it then recompiles the module, but forgets the generated-sources. What am I forgetting?
I am trying to use maven-assembly-plugin to build a lite and fat web application, the application will have different content later. I thought that I actually can use two profiles mvn -Pliteweb,fatweb package so it will create two build assembly for each profile. But when I run it, it actually only create one assembly that is in the bottom position in the pom ( the liteweb )
I already tried when I build it one by one its okay. I also check with mvn help:active-profiles -P fatweb,liteweb and it correctly show 2 active profile.
Below is my test pom ( its not including the difference in here, I just want it to create 2 War files and other assembly files separately ). I am still new at Maven so I might misunderstood this. Is creating multiple assembly from multiple profiles is possible to do?
<?xml version="1.0" encoding="UTF-8"?>
<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>com.test.web</groupId>
<artifactId>TEST_WEB</artifactId>
<packaging>war</packaging>
<name>WEB Application</name>
<version>0.0.1</version>
<properties>
<litewebPath>src/main/lite</litewebPath>
<fatwebPath>src/main</fatwebPath>
</properties>
<profiles>
<profile>
<id>fatweb</id>
<build>
<resources>
<resource>
<directory>${fatwebPath}/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<finalName>WEB-${project.version}</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptors>
<descriptor>fatassembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>exec1</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>liteweb</id>
<build>
<resources>
<resource>
<directory>${litewebPath}/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<finalName>LITEWEB-${project.version}</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptors>
<descriptor>liteassembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>exec2</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
fatassembly.xml for now I didnt put anything just to make sure everything work.
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>lib</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
</dependencySet>
</dependencySets>
</assembly>
liteassembly.xml same I didnt put anything to make sure everything work, but I already test with different thing inside still doesnt work.
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>lib-lite</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
</dependencySet>
</dependencySets>
</assembly>
When EXECUTING mvn help:active-profiles -Pfatweb,liteweb
Active Profiles for Project 'com.test.web:TEST_WEB:war:0.0.1':
The following profiles are active:
- fatweb (source: com.test.web:TEST_WEB:0.0.1)
- liteweb (source: com.test.web:TEST_WEB:0.0.1)
And below is what happen when I execute mvn -Pfatweb,liteweb clean package seems like it building the same zip twice.. From same xml assembly, but actually from different execution ( exec1 and exec2 )
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building WEB Application 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # TEST_WEB ---
[INFO] Deleting D:\PROJECT\POMTEST\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # TEST_WEB ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # TEST_WEB ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # TEST_WEB ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\PROJECT\POMTEST\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # TEST_WEB ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # TEST_WEB ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # TEST_WEB ---
[INFO] Packaging webapp
[INFO] Assembling webapp [TEST_WEB] in [D:\PROJECT\POMTEST\target\LITEWEB-0.0.1]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\PROJECT\POMTEST\src\main\webapp]
[INFO] Webapp assembled in [27 msecs]
[INFO] Building war: D:\PROJECT\POMTEST\target\LITEWEB-0.0.1.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- maven-assembly-plugin:2.6:single (exec1) # TEST_WEB ---
[INFO] Reading assembly descriptor: liteassembly.xml
[INFO] Building zip: D:\PROJECT\POMTEST\target\LITEWEB-0.0.1-lib-lite.zip
[INFO]
[INFO] --- maven-assembly-plugin:2.6:single (exec2) # TEST_WEB ---
[INFO] Reading assembly descriptor: liteassembly.xml
[INFO] Building zip: D:\PROJECT\POMTEST\target\LITEWEB-0.0.1-lib-lite.zip
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.961 s
[INFO] Finished at: 2016-06-14T15:23:05+08:00
[INFO] Final Memory: 12M/229M
[INFO] ------------------------------------------------------------------------
So the profile actually active, but after that the one that build in target folder is only the LITEWEB. If anyone know, please help me to understand why it not create both and why mvn like build the zip twice. I know the workaround is just shellscript code to build twice (if I build one profile each time it work correctly), but I want to use only mvn specific build.
Below is what happen if I do mvn -Pfatweb,liteweb clean install the lib were created twice, but it only build the WAR file once. From the log I actually realized the one that build the WAR is the war-plugin, but how do I make it execute for both profile..?
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building WEB Application 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # TEST_WEB ---
[INFO] Deleting D:\PROJECT\POMTEST\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # TEST_WEB ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # TEST_WEB ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # TEST_WEB ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\PROJECT\POMTEST\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # TEST_WEB ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # TEST_WEB ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # TEST_WEB ---
[INFO] Packaging webapp
[INFO] Assembling webapp [TEST_WEB] in [D:\PROJECT\POMTEST\target\LITEWEB-0.0.1]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\PROJECT\POMTEST\src\main\webapp]
[INFO] Webapp assembled in [26 msecs]
[INFO] Building war: D:\PROJECT\POMTEST\target\LITEWEB-0.0.1.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- maven-assembly-plugin:2.6:single (exec1) # TEST_WEB ---
[INFO] Reading assembly descriptor: fatassembly.xml
[INFO] Building zip: D:\PROJECT\POMTEST\target\LITEWEB-0.0.1-lib.zip
[INFO]
[INFO] --- maven-assembly-plugin:2.6:single (exec2) # TEST_WEB ---
[INFO] Reading assembly descriptor: liteassembly.xml
[INFO] Building zip: D:\PROJECT\POMTEST\target\LITEWEB-0.0.1-lib-lite.zip
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # TEST_WEB ---
[INFO] Installing D:\PROJECT\POMTEST\target\LITEWEB-0.0.1.war to C:\Users\rm\.m2\repository\com\test\web\TEST_WEB\0.0.1\TEST_WEB-0.0.1.war
[INFO] Installing D:\PROJECT\POMTEST\pom.xml to C:\Users\rm\.m2\repository\com\test\web\TEST_WEB\0.0.1\TEST_WEB-0.0.1.pom
[INFO] Installing D:\PROJECT\POMTEST\target\LITEWEB-0.0.1-lib.zip to C:\Users\rm\.m2\repository\com\test\web\TEST_WEB\0.0.1\TEST_WEB-0.0.1-lib.zip
[INFO] Installing D:\PROJECT\POMTEST\target\LITEWEB-0.0.1-lib-lite.zip to C:\Users\rm\.m2\repository\com\test\web\TEST_WEB\0.0.1\TEST_WEB-0.0.1-lib-lite.zip
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.768 s
[INFO] Finished at: 2016-06-16T10:49:10+08:00
[INFO] Final Memory: 12M/174M
[INFO] ------------------------------------------------------------------------
In your POM move your <configuration> section FROM being under <plugin> TO being under <execution>. Do this for both <configuration> sections.
The error is that you configured the plugin 2 times. When both profiles are active, maven merges the 2 configurations, loosing one.
I am trying to execute pom.xml having mainClass mentioned in it but it is not being executed.
command : mvn test -f "path_to_pom.xml\pom.xml"
Output:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) #Project ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # Project ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Project ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Personal\selenium\Project\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) #Project ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 5 source files to D:\Personal\selenium\Project\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # Project ---
[WARNING] useSystemClassloader setting has no effect when not forking
[INFO] Surefire report directory: D:\Personal\selenium\Project\target\surefire-reports
Running test.java.com.utilities.TestController
Configuring TestNG with: TestNG652Configurator
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.295 sec - in t
est.java.com.utilities.TestController
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.138 s
[INFO] Finished at: 2016-03-08T11:45:54+05:30
[INFO] Final Memory: 20M/225M
[INFO] ------------------------------------------------------------------------
I tried executing it from eclipse IDE but is not being executed from there too.
However, specifying -DmainClass="<className>" in the maven command on cmd, class is being executed.
Below is the entry from pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>test.java.com.utilities.TestController</mainClass>
</configuration>
</plugin>
I already did mvn clean and Maven > Update Project but it did not helped.
Question: What other changes can I do to make this work?
You want to execute the class during your test phase, hence you should add it to your plugin execution. Moreover, it seems you are running a class from the test packages which may also need test classpath to properly execute.
I would then apply the following change to the configuration you posted:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>test</phase> <!-- ADDED -->
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>test.java.com.utilities.TestController</mainClass>
<classpathScope>test</classpathScope> <!-- ADDED -->
</configuration>
</plugin>
Note the ADDED elements highlighted through comments.
I am trying to minify some JavaScript and getting it to the right location within the Maven build process. We're using the 1.5 JDK, which limits some of the options available to me to accomplish this task. It appears that I have set up the plugins in the right order, but I believe that during the WAR assembly process, the work I performed during the prepare-package goal is being overwritten. Below is the build portion of the POM and the partial results (abbreviated for clarity). Any assistance offered in welcomed. Thanks!
<build>
<plugins>
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>minify</goal>
</goals>
<configuration>
<verbose>true</verbose>
<jsSourceDir>broker/app</jsSourceDir>
<jsSourceFiles>
<jsSourceFile>controller/Navigation.js</jsSourceFile>
<jsSourceFile>view/MainView.js</jsSourceFile>
</jsSourceFiles>
<jsFinalFile>minified.js</jsFinalFile>
<webappTargetDir>${project.basedir}/src/main/webapp/broker/app/controller</webappTargetDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="processing files..."/>
<copy
file="${project.basedir}/src/main/webapp/broker/app/controller/js/minified.min.js"
tofile="target/${project.build.finalName}/broker/app/controller/Navigation.js"
overwrite="true"
verbose="true"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>broker/app/controller/Navigation.js, broker/app/view/MainView.js</packagingExcludes>
<archive>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Title>${project.name}</Implementation-Title>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
output from process
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building VFIS AS RQ WAR Module 1.0.0.37-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # rq-vfis-as-war ---
[INFO] Deleting C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target
[INFO]
[INFO] --- minify-maven-plugin:1.5.2:minify (default) # rq-vfis-as-war ---
[INFO] Processing source file [Navigation.js].
[INFO] Processing source file [MainView.js].
[INFO] Creating merged file [minified.js].
[INFO] Creating minified file [minified.min.js].
<snipped output>
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) # rq-vfis-as-war ---
[INFO] Executing tasks
[echo] processing files...
[copy] Copying 1 file to C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\rq-vfis-as-war-1.0.0.37-SNAPSHOT\broker\app\controller
[copy] Copying C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\src\main\webapp\broker\app\controller\js\minified.min.js to C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\rq-vfis-as-war-1.0.0.37-SNAPSHOT\broker\app\controller\Navigation.js
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # rq-vfis-as-war ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # rq-vfis-as-war ---
[INFO] Compiling 35 source files to C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) # rq-vfis-as-war ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # rq-vfis-as-war ---
[INFO] Compiling 10 source files to C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) # rq-vfis-as-war ---
[INFO] Surefire report directory: C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
<snipped test results>
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # rq-vfis-as-war ---
[INFO] Packaging webapp
[INFO] Assembling webapp [rq-vfis-as-war] in [C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\rq-vfis-as-war-1.0.0.37-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\src\main\webapp]
[INFO] Webapp assembled in [7816 msecs]
[INFO] Building war: C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\rq-vfis-as-war-1.0.0.37-SNAPSHOT.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.266s
[INFO] Finished at: Wed Apr 30 09:38:29 EDT 2014
[INFO] Final Memory: 41M/111M
[INFO] ------------------------------------------------------------------------
Use <warSourceExcludes>broker/app/controller/Navigation.js,broker/app/view/MainView.js</warSourceExcludes> instead.