How to keep Maven profiles which are activeByDefault active even if another profile gets activated?

One trick is to avoid activeByDefault, and instead activate the profile by the absence of a property, eg: <profiles> <profile> <id>firstProfile</id> <activation> <property> <name>!skipFirstProfile</name> </property> </activation> … </profile> </profiles> You should then be able to deactivate the profile with -DskipFirstProfile or with -P !firstProfile, but otherwise the profile will be active. See: Maven: The Complete … Read more

maven-assembly-plugin doesn’t add dependencies with system scope

you can do it by adding this dependencySet to your assembly file descriptor <dependencySet> <outputDirectory>/</outputDirectory> <unpack>true</unpack> <scope>system</scope> </dependencySet> this assembly descriptor add all dependencies including system scoped <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>jar-with-all-dependencies</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <outputDirectory>/</outputDirectory> <useProjectArtifact>true</useProjectArtifact> <unpack>true</unpack> <scope>runtime</scope> </dependencySet> <dependencySet> <outputDirectory>/</outputDirectory> <unpack>true</unpack> <scope>system</scope> </dependencySet> </dependencySets> </assembly>

Share test resources between maven projects

Just use jar:test-jar and declare the resulting JAR as a dependency (refer to this guide for more details). And while I don’t understand the problem of having resources and classes in this jar, you can always exclude all .class files: <project> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.2</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> <configuration> … Read more

Use public maven repository with ivy

You need to add an ivysettings.xml file with the following repositories listed (resolvers in ivy speak) <ivysettings> <settings defaultResolver=”chain”/> <resolvers> <chain name=”chain”> <ibiblio name=”central” m2compatible=”true”/> <ibiblio name=”example” m2compatible=”true” root=”http://example.com/m2/”/> </chain> </resolvers> </ivysettings> In my opinion it makes more sense to separate the dependency declaration (ivy.xml) from the mechanism of retrieval (settings.xml). This is not needed … Read more

Setting Java heap space under Maven 2 on Windows

The environment variable to set is MAVEN_OPTS, for example MAVEN_OPTS=-Xmx1024m. The maxmem configuration in the pom only applies when you set the compiler plugin to fork javac into a new JVM. Otherwise the plugin runs inside the same VM as Maven and thus within the memory passed on the command line via the MAVEN_OPTS. To … Read more