Setting up Ptolemy II using Maven

Setting up Ptolemy II using Maven

Note that building Ptolemy II with Maven requires an Internet connection. The mvn compile step will download modules from the net.

These notes are based on Tristan King's work, see his July 21, 2008 ptolemy-hackers post: updates on ptII maven and work.

Setting up Maven

  1. Download Maven from


  1. Download Ptolemy II using svn and set the $PTII environment variable.
    		cd /path/to/working/directory/
    		svn co svn:// ptII
    		export PTII=/path/to/working/directory/ptII
  2. Optional: Delete $PTII/vendors
    		rm -r $PTII/vendors
  3. Make sure that when in $PTII, $PTII==pwd:
                    bash-3.2$ cd $PTII
                    bash-3.2$ echo $PTII
                    bash-3.2$ pwd
    If the current working directory is a symbolic link to the actual directory where $PTII is located, then be sure to change either $PTII or the current working directory so they both match.
  4. Set MAVEN_OPTS to configure maven to use large amounts of memory
    		export MAVEN_OPTS="-Xms512m -Xmx512m -XX:PermSize=48m"
  5. Configure Ptolemy II to Exclude the Eclipse plugi:
                   ./configure --without-eclipse
    FIXME: $PTII/pom.xml needs to be extended to include support for Eclipse, see below
  6. Tell Maven about the jar files necessary to compile:
    mvn install:install-file -DgroupId=jython -DartifactId=jython \
    -Dversion=svn -Dpackaging=jar -Dfile=$PTII/vendors/jython/jython.jar
    mvn install:install-file -DgroupId=javajoystick -DartifactId=joystick \
    -Dversion=0.7 -Dpackaging=jar -Dfile=$PTII/vendors/misc/joystick/Joystick.jar 
    mvn install:install-file -DgroupId=jxta -DartifactId=jxta -Dversion=1.0 \
    -Dpackaging=jar -Dfile=$PTII/vendors/sun/jxta/jxta.jar
    mvn install:install-file -DgroupId=jxta -DartifactId=jxtasecurity -Dversion=1.0 \
    -Dpackaging=jar -Dfile=$PTII/vendors/sun/jxta/jxtasecurity.jar
    mvn install:install-file -DgroupId=soot -DartifactId=sootclasses -Dversion=ptII \
    -Dpackaging=jar -Dfile=$PTII/lib/sootclasses.jar
    mvn install:install-file -DgroupId=mapss -DartifactId=mapss -Dversion=ptII \
    -Dpackaging=jar -Dfile=$PTII/lib/mapss.jar
    mvn install:install-file -DgroupId=caltrop -DartifactId=ptCal -Dversion=ptII \
    -Dpackaging=jar -Dfile=$PTII/lib/ptCal.jar
    mvn install:install-file -DgroupId=chic -DartifactId=chic -Dversion=ptII \
    -Dpackaging=jar -Dfile=$PTII/lib/chic.jar
    mvn install:install-file -DgroupId=jacl -DartifactId=jacl -Dversion=ptII \
    -Dpackaging=jar -Dfile=$PTII/lib/ptjacl.jar
  7. Run vergil! This can be done in a few different ways:
    1. Run vergil using maven.
      		cd /path/to/ptII-maven/
      		mvn compile
      		mvn exec:exec
      Note that mvn exec:exec requires net access. To run offline, run: mvn -o exec:exec
    2. Build a ptolemy II jar and run vergil from would look like:
      java -classpath $PTII/target/ptII-7.1.devel-SNAPSHOT.jar:~/.m2/repository/caltrop/ptCal/unknown/ptCal-unknown.jar:~/.m2/repository/net/jini/jini-core/2.1/jini-core-2.1.jar:~/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar:~/.m2/repository/javax/jms/jms/1.1/jms-1.1.jar:~/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar:/usr/lib/jvm/java-1.5.0-sun-

      	        # run these two steps only once
      		cd /path/to/ptII-maven/	
      		mvn package
      		# then
      Note that the version numbers are hardwired into the path, which is why this file is not checked in. Another issue is that this command build a jar file, which slows down the build/test cycle.

maven compile fails

Below are various issues that occurred during the build.
What about "make maven"?
mk/ includes a rule that will create a ptII/src directory. The current ptII/pom.xml file does not use this directory, so there is no need to run make maven
Problem: you need to be on line to compile
[INFO] artifact org.apache.maven.plugins:maven-resources-plugin: checking for updates from central
[WARNING] repository metadata for: 'artifact org.apache.maven.plugins:maven-resources-plugin' could not be retrieved from repository: central due to an error: Error transferring file
[INFO] Repository 'central' will be blacklisted
This can happen if there is no network connection when mvn compile is run.
Remove ~/.m2/repository/org/apache/maven/plugins/maven-resources-plugin or just remove all of ~/.m2.
Problem: antlr not found
1) antlr:antlr:jar:2.9.9

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=antlr -DartifactId=antlr \
          -Dversion=2.9.9 -Dpackaging=jar -Dfile=/path/to/file

  Path to dependency: 
  	1) edu.berkeley.eecs.ptolemy:ptII:jar:7.1.devel-SNAPSHOT
  	2) antlr:antlr:jar:2.9.9
mvn install:install-file -DgroupId=antlr -DartifactId=antlr -Dversion=svn -Dpackaging=jar -Dfile=$PTII/ptolemy/actor/ptalon/antlr/antlr.jar

Then rerun mvn compile

Problem: antlr still not found
Solution: Edit pom.xml and change the antlr version number from 2.9.9 to 2.7.7
Problem: ptalon
[INFO] The grammar '/Users/cxh/Documents/workspace/ptII/src/main/antlr/ptolemy/actor/ptalon/parser.g' doesnt exist.
Solution: copy the files
cd $PTII
mkdir -p src/main/antlr/ptolemy/actor/ptalon
cp $PTII/ptolemy/actor/ptalon/*.g src/main/antlr/ptolemy/actor/ptalon
However, it turned out that none of the files were being copied because $PTII was a symbolic link. See below.
Problem: can't start
Exception in thread "main" java.lang.NoClassDefFoundError: ptolemy/vergil/VergilApplication
It turns out that the java files were not copied to the right location. $PTII/target/ptII-7.1.devel-SNAPSHOT.jar only contained the antlr classes. The problem was that the toplevel directory where make maven was run was a symbolic link to the actual $PTII directory. The fix was to make sure that in $PTII, $PTII==pwd:
bash-3.2$ cd $PTII
bash-3.2$ echo $PTII
bash-3.2$ pwd
and then to run

make maven
mvn compile
Problem: compilation fails
/Users/cxh/Documents/workspace/ptII/src/main/java/ptolemy/moml/jxta/[44,27] package net.jxta.credential does not exist
Edit $PTII/pom.xml and uncomment the jxta section
Problem: compilation fails on Eclipse files
/Users/cxh/Documents/workspace/ptII/src/main/java/ptolemy/backtrack/eclipse/ast/transform/[36,32] package org.eclipse.jdt.core.dom does not exist
Proposed Solution: We use the Maven Eclipse Plugin
mvn -Declipse.workspace=/Applications/eclipse eclipse:add-maven-repo
mvn -DeclipseDir=/Applications/eclipse eclipse:to-maven
. However, our workaround is to just not copy the Eclipse plugin files to $PTII/src by running ./configure --without-eclipse.
"mvn package" fails because of backtracking
/Users/cxh/ptII/ptolemy/backtrack/eclipse/plugin/editor/[52,35] cannot find symbol
Solution: disable test-compile:

Maven and Web Start

  1. Install
    mvn install webstart:jnlp
has no matching file, why? Check the logs
When running maven webstart:jnlp, I get
Embedded error: artifact org.ptolemy:ptII:jar:7.2.devel has no matching file, why? Check the logs...
See "3.5.3. Maven Coordinates" of the maven manual, which describes the naming for artifacts. It turns out that the jnlp rule needed to have:

Maven and OSGI

Bundle Plugin for Maven

Maven Notes