I am looking for a JAR file generator fitting these requirements:
- Able to create jar files containing other jar files
- Makes creation and maintenance of manifest files easy.
For creating fat jars jarjar is a brilliant tool since it is easy to use, well maintained and has a good plugin support. It is also recommended by many libraries that typically require repacking such as ASM. Otherwise, build managers such as Maven or Gradle should offer you the functionality you are looking for out of the box. You should be able to pack recources in dependency of build profiles.
If you're looking to package your application together with its library JARs as one JAR file, you might consider the BSD-licensed One-Jar. One-Jar uses a custom classloader to load from JARs inside your main JAR file, while (based on its documentation) jarjar flattens all your classes into just one JAR file (no inner JARs), modifying class files as necessary.
Depending on your application, One-Jar's approach may work better (or worse) than jarjar's.
I think Maven is the tools that can do everything (with some configuration).
Exemple: I have a folder (./lib) where I have all my JAR files, I just have the following small pom.xml file like this:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.mycompany.test</groupId> <artifactId>bigjar</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <url>http://www.mycompany.com</url> <prerequisites> <maven>3.1.0</maven> </prerequisites> <!-- Put external dependencies here --> <dependencies> </dependencies> <build> <defaultGoal>install</defaultGoal> <resources> <resource> <directory>lib</directory> <filtering>true</filtering> </resource> </resources> </build> </project>
mvn clean install, and then you have all your lib/*.jar files in a new JAR.
If you need external Jars, you can just add it as a new dependency (in the section).