adam bien's blog

xplr: Utility For Migrations To Maven 📎

Java projects without dependency management directly rely on JARs contained in the project structure for compilation and deployment purposes.

A migration to maven requires the analysis of the JARs origin. All JARs needs to be replaced by dependencies defined in Maven's pom.xml. Sometimes the used JARs already contain maven information, in some cases the meta information is stored in the JAR's manifest.mf.

xplr is a self-contained, 15 kB, Java 8 CLI utility, which recursively traverses folders, searches for JARs and extracts any pom or manifest information. xplr also generates the mvn install:install-file statements which help you to install any proprietary libraries to the maven repository.

Applied to itself with java -jar target/xplr.jar . xplr produces the following output:


(...)
#####################################
Directory: ./target
#####################################

# Jar: ./target/xplr.jar
## Manifest: 
## Package: com.airhacks.xplr
Archiver-Version:Plexus Archiver
Built-By:abien
Created-By:Apache Maven 3.3.3
Build-Jdk:1.8.0_77
Manifest-Version:1.0
Main-Class:xplr.Explorer

## POM: 
<dependency>
 <groupId>com.airhacks</groupId>
 <artifactId>xplr</artifactId>
 <version>0.0.1</version>
 <packaging>jar</packaging>
</dependency>
## MVN install command: 
mvn install:install-file -Dfile=./target/xplr.jar 
-DgroupId=com.airhacks -DartifactId=xplr -Dversion=0.0.1 -Dpackaging=jar
---
(...)

With two parameters: java -jar xplr.jar [FOLDER] [CLASS NAME] xplr lists all JARs containing the specified class name (excerpts are supported). E.g.

java -jar target/xplr.jar . Injector will find:

#####################################
Directory: ./src/test/jars
#####################################

# Jar: ./src/test/jars/afterburner.fx-1.6.2.jar
## Manifest: 
## Package: com.airhacks.afterburner.configuration
Archiver-Version:Plexus Archiver
Built-By:abien
Created-By:Apache Maven 3.2.1
Build-Jdk:1.8.0_31
Manifest-Version:1.0

## POM: 
<dependency>
 <groupId>com.airhacks</groupId>
 <artifactId>afterburner.fx</artifactId>
 <version>1.6.2</version>
 <packaging>jar</packaging>
</dependency>
## MVN install command: 
mvn install:install-file -Dfile=./src/test/jars/afterburner.fx-1.6.2.jar 
-DgroupId=com.airhacks -DartifactId=afterburner.fx -Dversion=1.6.2 -Dpackaging=jar
---


xplr is apache licensed GitHub project: https://github.com/AdamBien/xplr. First release is available for download (15 kB).

Happy migrations! See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.