There’s nothing like a good sense of humor.
In order to assist the Apache Tomcat project I’ve recently taken to publishing versions of the Eclipse JDT Core Batch Compiler (ECJ) to the Maven Central repository. Tomcat is presently built with Ant, not Maven, and on occasion it’s published POM file for the Jasper JSP parser refers to ECJ dependencies that are not available in Maven Central. Today I’ve uploaded ECJ 3.7.1 (R-3.7.1-201109091335).
The process is well documented in Uploading 3rd-party Artifacts to Maven Central, but hopefully the following example makes it that much more accessible to others. I’ll assume you have Maven installed and are familiar with its basic usage.
- First one needs an OpenPGP key, with the public half published to an open key server. I found the Ubuntu GnuPrivacyGuardHowto very helpful in this regard, specifically sections 2 & 3. You’ll find my public key on Ubuntu’s key server.
- We’ll need some directories to work with:
1 2 3
mkdir -p ~/Development/ecj/3.7.1/src/main/java cd ~/Development/ecj/3.7.1/ mkdir -p target/classes
- We pull down the ECJ source and binaries from Eclipse. (Finding the drops for a given version generally entails fishing around http://download.eclipse.org/eclipse/downloads/.)
- Next we extract the downloads to the directories Maven expects:
4 5 6 7 8
cd src/main/java/ jar -xvf ~/Downloads/ecjsrc-3.7.1.jar org cd - ; cd target/classes jar -xvf ~/Downloads/ecj-3.7.1.jar org cd -
- Borrowing from those of prior versions we craft a suitable POM at the root of our working directory in a file named pom.xml.
- We create the artifact bundle with Maven:
mvn source:jar javadoc:jar package gpg:sign repository:bundle-create
Maven prompts for our OpenPGP private key’s password from step #1:
[INFO] --- maven-gpg-plugin:1.3:sign (default-cli) @ ecj --- GPG Passphrase: ************************
Note that the Java .class files will not be recreated because we extracted the binaries as they were built by Eclipse. This avoids any Java compiler version or target issues:
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ecj --- [INFO] Nothing to compile - all classes are up to date
We’ll be prompted whether to exclude any files from the bundle, but we want them all so just enter ’0′:
0.) Done 1.) ecj-3.7.1.jar 2.) ecj-3.7.1.jar.asc 3.) ecj-3.7.1.pom.asc 4.) ecj-3.7.1-javadoc.jar 5.) ecj-3.7.1-sources.jar 6.) ecj-3.7.1-javadoc.jar.asc 7.) ecj-3.7.1-sources.jar.asc Please select the number(s) for any files you wish to exclude, or '0' when you're done. Separate the numbers for multiple files with a comma (','). Selection: 0 [INFO] Building jar: /Users/ibrandt/Development/ecj/3.7.1/target/ecj-3.7.1-bundle.jar
- Now all that’s left to do is upload the bundle archive to https://oss.sonatype.org per the aforementioned guide.
For those wishing to see Eclipse artifacts regularly published to a Maven repository see http://wiki.eclipse.org/Maven, and place your votes here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=283745.