Intellij 13.1.2 not unpacking exploded (sub-) artifacts - maven

With Intellij < 13.1.2 we were able to locally have a exploded artifact with exploded subartifacts for development, the actual version 13.1.2 is putting out *.jar and *.war files instead of directories.
I found this workaround in their bugtracker: http://youtrack.jetbrains.com/issue/IDEA-124353
but was wondering how to achieve this for all modules, instead of having to list all of them?

Ok, I found my workaround by adding a maven profile for intellij and enabling it:
<profiles>
<profile>
<id>intellij</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<unpackTypes>war,ejb</unpackTypes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Related

Commit multiple files with maven scm plugin

I want to git commit two files in different folders with maven scm plugin (v1.9.4). Eg: abc/p.json and xyz\p.json. I dont want to commit any other files such as other/p.json
According to the documentation for the chekin goal, a comma separated list such as abc/p.json,xyz/p.json should work. But it ends up commiting all the files.
I am using the scm:checkin goal with the maven release plugin's <preparationGoals> configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven.release.plugin.version}</version>
<configuration>
<preparationGoals>
clean verify
scm:checkin -DpushChanges=false -Dmessage="[maven-release-plugin] Update version text"
-Dincludes="abc/p.json,xyz/p.json"
</configuration>
</plugin>
How do I commit just the abc/p.json and xyz/p.json files?
I was able to get a list of files checked in by creating a profile, similar to:
<profile>
<id>commit-changed-files</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<configuration>
<includes>file1,file2,file3,file4</includes>
<message>[maven-release-plugin] commit changed files</message>
<pushChanges>false</pushChanges><!-- because I use git -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
And then, in the release plugin configuration:
<preparationGoals>-Pcommit-changed-files clean scm:add scm:checkin</preparationGoals>
<completionGoals>-Pcommit-changed-files clean scm:add scm:checkin</completionGoals>
Reference: formatter-m2e-configurator's pom.xml

How to configure maven jar plugin to exclude properties on profile

I have this configuration in my pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<excludes>
<exclude>**/logging/*</exclude>
<exclude>**/config/*</exclude>
</excludes>
</configuration>
</plugin>
I use profiles to handle different behaviour from local environment to production environment.
Is it possible not activate the exclusions when executing mvn install with local profile?
I tried to set a blank properties on local environment like this
but the plugin complains.
This is a workaround solution, maybe a better one exists. I think the easiest you could do is to let your DEV environment free from any config of the jar plugin. And then place your PROD config in a dedicated profile :
<profiles>
<profile>
<id>PROD</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<excludes>
<exclude>**/logging/*</exclude>
<exclude>**/config/*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
When you need to build the production jar, launch :
mvn clean install -PPROD
Are the logging and config files resources for testing only? If yes, put them in ${basedir}/src/test/resources. They'll be on the classpath for your tests but will not end up in the final jar, and you won't need specific jar plugin config.
The best workaround I found is to use an invalid value to filter on when executing on DEV environment.
<profiles>
<profile>
<id>env-local</id>
<activation>
<property>
<name>env</name>
<value>local</value>
</property>
</activation>
<properties>
<jndi.iban0>cont0Data</jndi.iban0>
<config.file.path>classpath:config</config.file.path>
<logging.file.path>classpath:logging</logging.file.path>
<exclude.logging>none</exclude.logging>
<exclude.config>none</exclude.config>
</properties>
</profile>
</profiles>

exclude TestNG-Groups on maven build in hudson

I want to use hudson to build a maven-java project. Some of my integration tests use servers which are not reachable from the hudson-server. So i want to exclude them using a special profile.
<profile>
<id>hudson</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<excludedGroups>ticketserver,print</excludedGroups>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profile
Unfortunatly i am already excluding a group in my general pom.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.10</version>
<configuration>
<excludedGroups>manual</excludedGroups>
</configuration>
Using mvn help:effective-pom i found out, that this setting overrides the one from my profile. Is there are way exclude all three test-classes when running in the hudson profile?
I though about putting the failsage-configuration in to every profile i have and removing it from the general pom but that does seem right, as i would need to repeat it for every profile i have.
Any help is greatly appreciated
Solved this by defining a property "testGroupsToSkip", which is set in the main-pom. it is then used as the value for excludedGroups. In my Profile i overwrite the property with the new value.

Maven - Calling a module from Parent POM based on the profile

I have a module which is supposed to produce two artifacts (war's). The only difference between the two WAR's is the web.xml being used.
I did this with the help of Maven Profiles...
<parent>
<artifactId>com</artifactId>
<groupId>myProj</groupId>
<version>1.0</version>
</parent>
<groupId>myProj.module1</groupId>
<artifactId>module1</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<profiles>
<profile>
<id>module1</id>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>module1</warName>
<webXml>src\main\webapp\WEB-INF\web_module1.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>module2</id>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>module2</warName>
<webXml>src\main\webapp\WEB-INF\web_module2.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Q1: How can I call this POM from super POM so that both the Profiles are activated?
Q2: Is it possible to install both the generated artifacts in Local repository?
Thanks!
When you want to activate several profiles at the same time, you simply have to run mvn ... -Pprofile1,profile2 command.
However, in your case, this is against one main Maven convention, which states that one project = one artifact. This means that you can't create 2 WAR at the same time. If you activate both profiles, one configuration of the maven-war-plugin will be overriden by the second profile, and then, you will finally get 1 WAR, with one web.xml.
If you want to get 2 WARs, the solution are to use WAR overlay (i.e. the second war is another project that depends on war #1), or run two separate Maven commands, one per profile.

change deployed artifact name based on profile

I have in a web application's pom file, a build profile, which does some necessary things (in my code) for qa testing.
I have this code on svn and this code is compiled in Hudson, which deploys artifacts in nexus..
Hudson has two jobs, one for qa profile (-P qa) and one for customers.
What i need is that i change in my qa profile the artifact's name during deploy phase, so that nexus has two different war files, one for qa and one for customer.
I use (after Google search) the following which looks like it does nothing in hudshon!
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<configuration>
<classifier>qa</classifier>
</configuration>
</plugin>
</plugins>
</build>
</profile>
any ideas someone?
You actually need to set the "classifier" configuration option on the plugin that's building the package that's being deployed: maven-(ear|ejb|jar|rar|war|shade)-plugin:
For instance, to build a WAR with a qa classifier, you would do the following:
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<classifier>qa</classifier>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Also, instead of setting the classifier you could set any of the following (most default to project.build.finalName, so setting that property updates many of these):
General
project.build.finalName
War Plugin
warName
Ear|Jar|Rar|Shade Plugin
finalName
EJB Plugin
jarName
One final note: I never realized this before, but looking over the documentation, it looks like the RAR plugin doesn't support the "classification" option. Shade does support the classifier concept, but does it via the "shadedClassifierName" property.

Resources