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.
Related
How are the dependencies for JSON Processing, JSR 374, handled from gradle? Working examples would be greatly appreciated.
context: below is what I have with maven; looking to migrate this to gradle.
build is ok, even if there are duplicates:
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
thufir#dur:~/NetBeansProjects/HelloJsonMaven$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloJsonMaven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # HelloJsonMaven ---
[INFO] Deleting /home/thufir/NetBeansProjects/HelloJsonMaven/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # HelloJsonMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # HelloJsonMaven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /home/thufir/NetBeansProjects/HelloJsonMaven/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # HelloJsonMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/thufir/NetBeansProjects/HelloJsonMaven/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # HelloJsonMaven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # HelloJsonMaven ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # HelloJsonMaven ---
[INFO] Building jar: /home/thufir/NetBeansProjects/HelloJsonMaven/target/HelloJsonMaven-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-shade-plugin:3.1.0:shade (default) # HelloJsonMaven ---
[INFO] Including javax.json:javax.json-api:jar:1.1 in the shaded jar.
[INFO] Including org.glassfish:javax.json:jar:1.0.4 in the shaded jar.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] javax.json-1.0.4.jar, javax.json-api-1.1.jar define 25 overlapping classes:
[WARNING] - javax.json.stream.JsonParser
[WARNING] - javax.json.stream.JsonParserFactory
[WARNING] - javax.json.JsonString
[WARNING] - javax.json.JsonValue
[WARNING] - javax.json.stream.JsonLocation
[WARNING] - javax.json.Json
[WARNING] - javax.json.stream.JsonParsingException
[WARNING] - javax.json.stream.JsonParser$Event
[WARNING] - javax.json.JsonWriter
[WARNING] - javax.json.JsonValue$ValueType
[WARNING] - 15 more...
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /home/thufir/NetBeansProjects/HelloJsonMaven/target/HelloJsonMaven-1.0-SNAPSHOT.jar with /home/thufir/NetBeansProjects/HelloJsonMaven/target/HelloJsonMaven-1.0-SNAPSHOT-shaded.jar
[INFO] Dependency-reduced POM written at: /home/thufir/NetBeansProjects/HelloJsonMaven/dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.616 s
[INFO] Finished at: 2017-10-21T12:15:07-07:00
[INFO] Final Memory: 18M/61M
[INFO] ------------------------------------------------------------------------
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
and the JAR actually runs:
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
thufir#dur:~/NetBeansProjects/HelloJsonMaven$ java -jar target/HelloJsonMaven-1.0-SNAPSHOT.jar
Oct 21, 2017 12:15:19 PM net.bounceme.dur.hello_json_maven.Main props
INFO: {foo=bar}
Oct 21, 2017 12:15:20 PM net.bounceme.dur.hello_json_maven.JsonOperations createJsonObject
INFO: creating..
Oct 21, 2017 12:15:20 PM net.bounceme.dur.hello_json_maven.Main json
INFO: {"name":"Falco","age":3,"biteable":false}
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
sample code:
package net.bounceme.dur.hello_json_maven;
import java.math.BigDecimal;
import java.util.logging.Logger;
import javax.json.Json;
import javax.json.JsonObject;
public class JsonOperations {
private static final Logger log = Logger.getLogger(JsonOperations.class.getName());
public void loadJsonFromFile(String jsonFileName) {
log.info(jsonFileName);
}
public JsonObject createJsonObject() {
// Create Json and serialize
log.info("creating..");
JsonObject json = Json.createObjectBuilder()
.add("name", "Falco")
.add("age", BigDecimal.valueOf(3))
.add("biteable", Boolean.FALSE).build();
String result = json.toString();
log.fine(json.toString());
return json;
}
}
Having been down this road before, seems prudent to ask before going too far down any false paths.
pom:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.bounceme.dur</groupId>
<artifactId>HelloJsonMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>net.bounceme.dur.hello_json_maven.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax.json/javax.json-api -->
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
</project>
When I use mvn clean package -DskipTests the console shows:
WEB-INF\web.xml already added, skipping
This does no harm if web.xml does not refer to any parameter in pom. But if you have a path that takes parameters from maven then this would leave the string as it is.
So how does this web.xml copy competition come out? and how to solve it?
console:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building wx-common 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # wx-common ---
[INFO] Deleting D:\FROM WORKSPACE\workspace\wxflow\wx-common\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:copy-resources (copy-resources) # wx-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # wx-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 14 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # wx-common ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 176 source files to D:\FROM WORKSPACE\workspace\wxflow\wx-common\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # wx-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\FROM WORKSPACE\workspace\wxflow\wx-common\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # wx-common ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 20 source files to D:\FROM WORKSPACE\workspace\wxflow\wx-common\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # wx-common ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # wx-common ---
[INFO] Packaging webapp
[INFO] Assembling webapp [wx-common] in [D:\FROM WORKSPACE\workspace\wxflow\wx-common\target\wx-common-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\FROM WORKSPACE\workspace\wxflow\wx-common\src\main\webapp]
[INFO] Webapp assembled in [267 msecs]
[INFO] Building war: D:\FROM WORKSPACE\workspace\wxflow\wx-common\target\wx-common-0.0.1-SNAPSHOT.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
pom profile and build:
<profiles>
<profile>
<id>dev</id>
<properties>
<deploy.type>dev</deploy.type>
<rp.build.warname>wx-common</rp.build.warname>
<property.path>/wx-common/prod</property.path>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/${deploy.type}</directory>
<filtering>true</filtering>
<excludes>
<exclude>sms.properties</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/dev/*</exclude>
</excludes>
<includes>
<include>**/mappers/*</include>
<include>*</include>
</includes>
</resource>
</resources>
</build>
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.
everyone. I'm trying to sign an Android APK with Maven Jarsigner. I followed the instructions on the maven-jarsigner site and told it to use my own keystore and verify. It doesn't look like the jarsigner plugin is even running from my pom.xml, much less verifying. I'm using Codenvy as my environment right now, so Maven console commands are unavailable to me. Any help would be appreciated. Here's my pom.xml:
<?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>org.kealinghornets.mapsapplication</groupId>
<artifactId>mobile-android-java-basic</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>MapsApp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>4.1.1.4</platform.version>
<android.plugin.version>3.8.0</android.plugin.version>
<android.sdk.platform.version>20</android.sdk.platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.jdroidframework</groupId>
<artifactId>google-play-services</artifactId>
<type>apklib</type>
<version>LATEST</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>java</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<defaultGoal>install</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign</id>
<goals>
<goal>sign</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>${project.basedir}/mapsapp.keystore</keystore>
<storepass>maps_app</storepass>
<keypass>maps_app</keypass>
<alias>maps_app</alias>
<verbose>true</verbose>
<certs>true</certs>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<sign>
<debug>false</debug>
</sign>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>${android.sdk.platform.version}</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
Here's my Maven output from the build:
[INFO] Injecting source code into builder...
[INFO] Source code injection finished
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MapsApp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # mobile-android-java-basic ---
[INFO]
[INFO] --- android-maven-plugin:3.8.0:generate-sources (default-generate-sources) # mobile-android-java-basic ---
[DEBUG] Expanding: /home/codenvy/.m2/repository/com/jdroidframework/google-play-services/0.6.0/google-play-services-0.6.0.apklib into /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, -m, -J, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/r, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar]
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, --non-constant-id, -m, -J, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/r, --custom-package, com.google.android.gms, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar]
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) # mobile-android-java-basic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/src/main/resources
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/extracted-dependencies/src/main/resources
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/src
[INFO]
[INFO] --- android-maven-plugin:3.8.0:consume-aar (default-consume-aar) # mobile-android-java-basic ---
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # mobile-android-java-basic ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes
[INFO]
[INFO] --- android-maven-plugin:3.8.0:proguard (default-proguard) # mobile-android-java-basic ---
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) # mobile-android-java-basic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # mobile-android-java-basic ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # mobile-android-java-basic ---
[INFO] No tests to run.
[INFO]
[INFO] --- android-maven-plugin:3.8.0:emma (default-emma) # mobile-android-java-basic ---
[INFO]
[INFO] --- android-maven-plugin:3.8.0:dex (default-dex) # mobile-android-java-basic ---
[INFO] /usr/local/jdk1.7.0_71/jre/bin/java [-Xmx1024M, -jar, /usr/local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar, --dex, --output=/media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes.dex, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes, /home/codenvy/.m2/repository/com/jdroidframework/google-play-services/0.6.0/google-play-services-0.6.0.apklib, /home/codenvy/.m2/repository/android/google-play-services/r21/google-play-services-r21.jar, /home/codenvy/.m2/repository/com/google/android/support-v4/r7/support-v4-r7.jar]
[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) # mobile-android-java-basic ---
[INFO] Building jar: /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.jar
[INFO]
[INFO] --- android-maven-plugin:3.8.0:apk (default-apk) # mobile-android-java-basic ---
[INFO] Enabling debug build for apk.
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, -f, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar, -F, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.ap_, --debug-mode]
[INFO]
[INFO] --- android-maven-plugin:3.8.0:internal-pre-integration-test (default-internal-pre-integration-test) # mobile-android-java-basic ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO]
[INFO] --- android-maven-plugin:3.8.0:internal-integration-test (default-internal-integration-test) # mobile-android-java-basic ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # mobile-android-java-basic ---
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.apk to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.apk
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/pom.xml to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.pom
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.jar to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.161s
[INFO] Finished at: Thu Feb 26 19:57:09 UTC 2015
[INFO] Final Memory: 22M/398M
[INFO] ------------------------------------------------------------------------
[INFO] Project androidmaps successfully build
The maven-jarsigner-plugin is declared inside pluginManagement section, so it will not be executed. pluginManagement is only supposed to be used to factor configuration on a plugin for different Maven modules.
Note that the android-maven-plugin is in fact executed because it it also declared inside the plugins section, so it inherits from the declaration made in pluginManagement.
You should move the maven-jarsigner-plugin code into the plugins section.