Archive for the ‘maven 2’ Category
« Older EntriesPer-assembly filtering with the maven-assembly-plugin
Monday, January 18th, 2010
Posted in: filtering, maven assembly plugin J2EE, java, maven 2.
The maven assembly plugin is an extremely powerful tool when it comes to creating custom distributions (aka assemblies) of your artifacts for individual platforms etc. However, the ability to create multiple variants of an artifact within a single build conflicts with the standard maven approach of using multiple build profiles and executing a single build for each profile to generate artifact variants.
This also means that mavens resource filtering is not very useful for individual assemblies, since you can only replace placeholders such as ${someValue} with the same value for all assemblies (since resources are only filtered once, using the active profile(s), for all assemblies).
You can, however, configure the maven assembly plugin to use individual filter property files for each assembly using the <execution> section of the plugin configuration, like so:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>production</id>
<goals>
<goal>single</goal>
</goals>
<configuration>
<filters>
<filter>${project.basedir}/src/main/assembly/production.properties</filter>
</filters>
<finalName>${artifactId}-production-${version}</finalName>
<ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<phase>package</phase>
</execution>
<execution>
<id>integration</id>
<goals>
<goal>single</goal>
</goals>
<configuration>
<filters>
<filter>${project.basedir}/src/main/assembly/integration.properties</filter>
</filters>
<finalName>${artifactId}-integration-${version}</finalName>
<ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<phase>package</phase>
</execution>
</executions>
</plugin>
This snippet uses the same assembly descriptor (you can use any assembly descriptor, actually) to build individual artifacts for production and integration. Note that the ${project.basedir}/ prefix is a workaround for MASSEMBLY-150 and is nedded to avoid a nasty Failed to create assembly: Error filtering file ... Error loading property file 'src/main/...' error when executing the mojo from outside the module directory (say, for instance, in a mvn release:prepare…).
Filtering must be enabled in the assembly descriptor, like so:
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/xsd/assembly"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/xsd/assembly http://maven.apache.org/xsd/assembly-1.1.1.xsd">
...
<fileSets>
<fileSet>
<filtered>true</filtered>
...
</fileSet>
</fileSets>
</assembly>
Thanks to John Casey for suggesting this in MASSEMBLY-430!
No CommentsRunning mvn:release with Subversion 1.5.x
Monday, March 23rd, 2009
Posted in: J2EE, SCM, System engineering, java, maven 2, open source, subversion.
When attempting to prepare a release using maven and the maven-release-plugin, you are currently very likely to see your build fail with a message such as:
[INFO] Executing: svn --non-interactive copy --file /tmp/...commit . https://subversion..../tags/...
[INFO] Working directory: ...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to tag SCM
Provider message:
The svn tag command failed.
Command output:
svn: Commit failed (details follow):
svn: File '...' already exists
If you do, you are using subversion 1.5.x which no longer supports tagging from a local working copy, thus causing the unfortunately very misleading error message.
This is a known issue of the subversion sourcecode management (SCM) and there is a simple workaround:
Read the rest of “Running mvn:release with Subversion 1.5.x”
Maven, Surefire, remote debugging and the -javaagent switch
Monday, February 2nd, 2009
Posted in: J2EE, java, maven 2, spring.
When using maven surefire in conjunction with remote debugging (mvnDebug, for instance)
it seems necessary to disable forking of the test executions into separate processes, as the remote debugging works process wise. This is usually done by setting the the fork mode to never, e.g. by specifying -DforkMode=never on the command line.
This is, however, a misunderstanding. mvnDebug is there to enable debugging of the maven process and not of the surefire execution – and disabling forking may have various side effects. One of those is the use of Java agents. When using agents, e.g. for loadtime-weaving in the Spring Framework, one often specifies a -javaagent: as a JVM argument for surefire:
Read the rest of “Maven, Surefire, remote debugging and the -javaagent switch”
Repository search for maven artifacts
Monday, November 10th, 2008
Posted in: java, maven 2, open source.
Most of the maven users know the site www.mvnrepository.com which provides a nice lookup of maven artefacts.
Now there is also a newer site, www.mvnbrowser.com which currently performs better than mvnrepository. In addition, you can lookup repositories actually containing your desired artifact – now that’s sweet!
OutOfMemoryError using findbugs & continuum – and how to fix it.
Monday, April 21st, 2008
Posted in: continuum, java, maven 2.
When using findbugs through the findbugs maven plugin, one is very likely to see the maven build in continuum fail with an OutOfMemory-Exception like this:
Read the rest of “OutOfMemoryError using findbugs & continuum – and how to fix it.”
ContinuumBuildCancelledException in continuum
Monday, April 21st, 2008
Posted in: continuum, java, maven 2.
Users of continuum might see their builds fail with the following exception when running a little more voluminous build:
org.apache.maven.continuum.execution.ContinuumBuildCancelledException: The build was cancelled
Read the rest of "ContinuumBuildCancelledException in continuum"
Configuring custom username for maven’s scm with subversion and ssh
Monday, April 21st, 2008
Posted in: System engineering, continuum, java, maven 2, subversion.
I just stumbled over a nice little problem: When using the maven 2 changelog plugin, it automatically uses the configured <scm> settings and attempts to fetch the change history with them.
Unfortunately, such a setting usually does not contain a username, since this has to be provided by the actual team member connecting to version control.
Neither did i have any intention to configure a placeholder into the scm section, forcing the developers to mess with the maven settings.xml in order to provide their own username.
Luckily, after searching a while, i found a proper solution.
SSH allows an optional per-host specific username setting to be placed in a file called “config” located in the user’s .ssh directory, for example
File: ~/.ssh/config
Host my.host.name
User myusername
Thanks to Chad Humphries for posting the Solution on programming is hard.
It really wasn’t…
maven autocompletion für die shell (und windows)
Wednesday, March 26th, 2008
Posted in: System engineering, java, maven 2, ubuntu.
Beim Arbeiten mit maven stört die fehlende automatische Vervollständigung auf der Kommadozeile, insbesondere wenn man den Komfort einer ordentlichen unix-shell gewöhnt ist. Doch dem kann abgeholfen werden. Aktuelle Linux-Distributionen (und unter Windows CYGWIN) besitzen mit bash-completion eine einfache Schnittstelle zum Erweitern der Autocompletion.
Read the rest of “maven autocompletion für die shell (und windows)”
Fehler beim Lesen von Jar-Dateien mit maven & Spring
Friday, February 1st, 2008
Wer bspw. im Rahmen eines test-targets mit spring konfigurierte Klassen verwendet, kann auf folgende Fehlermeldung stoßen:
Error creating bean with name '....' defined in class path resource [....xml]: Invocation of init method failed; nested exception is
java.lang.RuntimeException: error trying to scan
Caused by: java.lang.RuntimeException: error trying to scan
Read the rest of “Fehler beim Lesen von Jar-Dateien mit maven & Spring”
Bibliotheks-Sourcecode mit maven in Eclipse integrieren
Wednesday, January 23rd, 2008
Posted in: eclipse, java, maven 2.
Wer seine Projekte mit Maven konfiguriert kommt in den Genuss, mit den passenden Plugins gleich die IDE-Konfiguration für seine Projekte geliefert zu bekommen.
Am bekanntesten dürfte dabei das maven-eclipse plugin sein.
Dieses erlaubt in der – Sektion eine Menge feiner Zusatzeinstellungen. Unter anderem werden mit folgendem Eintrag die Quellen Abhängiger Bibliotheken in ein Eclipse-Projekt eingebunden:
Read the rest of “Bibliotheks-Sourcecode mit maven in Eclipse integrieren”