Archive for January, 2009

Maven cheatsheet

Tuesday, January 6th, 2009

Search for maven artifacts


http://maven.ozacc.com/
http://www.mvnrepository.com/

Create a new project (standard application)


mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

Create a new project (web application)


mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=com.mycompany.app -DartifactId=my-webapp

Resolve all dependencies


mvn dependency:resolve

Resolve all dependencies & their source attachments


mvn dependency:sources

Analyze dependencies


mvn dependency:analyze

Generate Ant build files


mvn ant:ant

Remove target directory & all build data


mvn clean

Compile


mvn compile

Build the package (JAR is the default)


mvn package

Only compile the unit tests


mvn test-compile

Compile & execute unit tests


mvn test

Compile & execute a single test


mvn -Dtest=MySingleTest test

Copy all the dependencies to target/dependency


mvn dependency:copy-dependencies

Assemble a package with all dependencies included


mvn assembly:assembly -DdescriptorId=jar-with-dependencies

Assemble a package with the sources


mvn assembly:assembly -DdescriptorId=src
mvn source:jar
mvn source:test-jar

Skip the tests when packaging


mvn -Dmaven.test.skip=true ...

Install an external jar into our local repo


mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=/path/to/file

VCS Checkin


mvn -Dusername=username -Dpassword=password -Dmessage="Some message" scm:checkin

Prepare a release


mvn release:prepare

Translate 1.5+ project with retrotranslator


mvn package retrotranslator:translate-project

Crashing Javac

Sunday, January 4th, 2009

It seems that lately I have been crashing javac… :-(


An exception has occurred in the compiler (1.6.0_10-rc). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.

java.lang.NullPointerException
  at com.sun.tools.javac.comp.Check.checkCompatibleConcretes(Check.java:1215)
  at com.sun.tools.javac.comp.Check.checkCompatibleSupertypes(Check.java:1567)
  at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2674)
  at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2628)
  at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2564)
  at com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:525)
  at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:575)
  at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
  at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:397)
  at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2697)
  at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2628)
  at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2564)
  at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1036)
  at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:765)
  at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:730)
  at com.sun.tools.javac.main.Main.compile(Main.java:353)
  at com.sun.tools.javac.main.Main.compile(Main.java:279)
  at com.sun.tools.javac.main.Main.compile(Main.java:270)
  at com.sun.tools.javac.Main.compile(Main.java:69)
  at com.sun.tools.javac.Main.main(Main.java:54)

 

The thing mostly annoying about the situation is that it is messing up with my project plan!