Ok, I have been trying to setup an Maven 2 internal repository for our company (evaluated artifactory and proximity), dumped all our Maven 2 archetypes to the internal repository. So, configured settings.xml to reflect the shiny new repository and decided to try out one of archetype:create downloaded from the new repos, lo and behold the dreaded BUILD ERROR *%%$%, the archetype-plugin in all its wisdom refused to consider my new shiny repos (always going to the mothership central). After four hours of redeploying the archetype, changing repositories, settings.xml it turns out (thanks to google) it is an open issue with maven or the archetype-plugin. In any case the solution is to provide a -DremoteRepositories system property on the command line.
Maven 2 settings.xml
Strange thing, if you use a <activeByDefault>true</activeByDefault> in a profile, and then checking for activated profiles using mvn help:active-profiles, shows the profile id containing the above element (child of activation element) twice?? So does it mean it is activated twice? Anyways, I added a <activeProfiles> element in the settings.xml and removed the above element from the affected profile, now reissuing the mvn help:active-profiles, the profile id shows up only once.
Another one of those mysterious maven 2 things, sigh.
Maven 2, TestNG and Surefire-plugin
Since I have decided to use this blog as a easy access to find things that I don’t want to search all over, here is the way I configure my maven-2 projects with TestNG. Here is the relevant pom entry in <build><plugins>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4-SNAPSHOT</version> <configuration> <argLine>-Xms128m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m</argLine> <parallel>true</parallel> <suiteXmlFiles> <suiteXmlFile>src/test/config/testng.xml</suiteXmlFile> </suiteXmlFiles> </configuration> </plugin>
You must make sure that the plugin snapshot repository is configured in your pom.xml, otherwise the 2.4-SNAPSHOT jar will not be found. To do that make sure the following element is defined in the <pluginRepositories> element:
<pluginRepository> <id>apache-snapshots</id> <url>http://people.apache.org/repo/m2-snapshot-repository</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> <pluginRepository>
Note, I put all my TestNG configuration information in testng.xml. Without this file you would get all kinds of strange errors, when the surefire plugin triggers the test goal. Below is a sample testng.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="Sample_TestNG_Suite" verbose="4"> <test name="DefaultTestPackage"> <packages> <package name="org.anonymous.package"/> </packages> </test> </suite>
You also need to make sure the testNG <dependency> element is available in the pom, lit below
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>5.6</version> <scope>test</scope> <classifier>jdk15</classifier> </dependency>
Remember 5.6 is not yet available in central repositories, to install it locally use the following standard maven-2 install goal (NOTE: the whole command below is a single line)
$ mvn install:install-file -Dfile=testng-5.6-jdk15.jar -DgroupId=org.testng -DartifactId=testng -Dversion=5.6 -Dpackaging=jar \ -Dclassifier=jdk15 -DgeneratePom=true
That’s it, you should be good to go, just annotate (I use JDK5) your test POJO’s and surefire plugin will be triggered by the default maven2 lifecycle.