1 Java Project Manager (1JPM), is a Maven/Gradle alternative with a twist. It's a single Java file itself, which should be edited by you to configure your project.
Meaning instead of writing XML (Maven) or Groovy (Gradle), your build file is Java code too. To be more exact, you download/copy the JPM.java file into your project, open a terminal and execute:
- Java 11 and above:
java JPM.java build
- Java 8 to 10:
javac JPM.java && java -cp . JPM build
- Earlier Java versions are not supported
to build your project (build
is a task, which compiles and creates a jar file from your code).
If you want to include dependencies in the jar run build-fat
instead.
1JPM works in a very similar way to Gradle, however everything in 1JPM is a plugin (even all its tasks), and third-party plugins can be added simply by appending their Java code at the bottom of the JPM class (must be written in Java 8 and not use external dependencies).
class ThisProject extends JPM.Project {
static{
JPM.ROOT.pluginsAfter.add(new JPM.Plugin("deploy").withExecute((project) -> { // Register custom task
//deployToServer(project); // If it throws an exception the whole build stops
}));
JPM.Build.GET.pluginsAfter.add(new JPM.Plugin("").withExecute((project) -> {
// Run something after/before another task, in this case after the "build" task
}));
}
public ThisProject(List<String> argList) {
// Override default configurations
this.groupId = "com.mycompany";
this.artifactId = "my-project";
this.version = "1.0.0";
this.mainClass = "com.mycompany.MyMainClass";
this.jarName = "my-project.jar";
this.fatJarName = "my-project-with-dependencies.jar";
// Add some example dependencies
addDependency("junit", "junit", "4.13.2");
addDependency("org.apache.commons", "commons-lang3", "3.12.0");
//implementation("org.apache.commons:commons-lang3:3.12.0"); // Same as above but similar to Gradle DSL
// Add some compiler arguments
addCompilerArg("-Xlint:unchecked");
addCompilerArg("-Xlint:deprecation");
}
}
// 1JPM version 1.0.2 by Osiris-Team
public class JPM {
//...
}
1JPM is a comparatively new project, thus does not contain all the functionalities of the other major build tools like Maven and Gradle, however should provide the basic and most used functions.
Below you can see some Gradle tasks that are available in 1JPM (or planned).
clean
: ✅ Deletes the build directory.compileJava
: ✅ Compiles Java source files.- Sub-task:
compileJava.options.compilerArgs
: ✅ Configures Java compiler arguments.
- Sub-task:
processResources
: ✅ Processes resource files (e.g., copying them to the output directory).- Sub-task:
processResources.expand(project.properties)
: ✅ Expands placeholders in resource files.
- Sub-task:
classes
: ✅ Assembles the compiled classes (depends oncompileJava
andprocessResources
).compileTestJava
: Compiles test Java source files.processTestResources
: Processes test resource files.testClasses
: Assembles the compiled test classes (depends oncompileTestJava
andprocessTestResources
).test
: Runs the unit tests (depends ontestClasses
).- Sub-task:
test.useJUnitPlatform()
: Configures JUnit Platform for testing.
- Sub-task:
jar
: ✅ Assembles the JAR file.- Sub-task:
jar.manifest
: ✅ Configures the JAR manifest.
- Sub-task:
javadoc
: Generates Javadoc for the main source code.assemble
: ✅ Assembles the outputs of the project (depends onclasses
andjar
).check
: Runs all checks (depends ontest
).build
: ✅ Aggregates all tasks needed to build the project (depends onassemble
andcheck
).
clean
: ✅ Deletes the build directory.cleanTask
: Deletes the output of a specific task (e.g.,cleanJar
,cleanTest
).
compileTestJava
: Compiles test Java source files.processTestResources
: Processes test resource files.testClasses
: Assembles the compiled test classes.test
: Runs the unit tests.- Sub-task:
test.include
: Specifies which test classes to run. - Sub-task:
test.exclude
: Specifies which test classes to exclude.
- Sub-task:
integrationTest
: Runs integration tests (custom task, needs configuration).
compileJava
: ✅ Compiles Java source files.processResources
: ✅ Processes resource files.classes
: ✅ Assembles the compiled classes.jar
: ✅ Assembles the JAR file.fatJar
: ✅ Creates a fat JAR with all dependencies (requires Shadow plugin).assemble
: ✅ Aggregatesclasses
andjar
tasks.
compileTestJava
: Compiles test Java source files.processTestResources
: Processes test resource files.testClasses
: Assembles the compiled test classes.test
: Runs the unit tests.checkstyle
: Runs Checkstyle for code style checks (requires Checkstyle plugin).pmdMain
: Runs PMD for static code analysis (requires PMD plugin).spotbugsMain
: Runs SpotBugs for bug detection (requires SpotBugs plugin).check
: Aggregates all verification tasks, includingtest
,checkstyle
,pmdMain
, andspotbugsMain
.
dependencies
: ✅ Displays the dependencies of the project.dependencyInsight
: Shows insight into a specific dependency.dependencyUpdates
: ✅ Checks for dependency updates.
help
: ✅ Displays help information about the available tasks and command-line options.components
: Displays the components produced by the project.
tasks
: ✅ Lists the tasks in the project.tasks --all
: Lists all tasks, including task dependencies.
compileJava
: ✅ Compiles Java source files.processResources
: ✅ Processes resource files.classes
: ✅ Assembles the compiled classes.jar
: ✅ Assembles the JAR file.- Sub-task:
jar.manifest.attributes
: Sets manifest attributes. - Sub-task:
jar.from
: Includes additional files in the JAR.
- Sub-task:
generatePomFileForMavenPublication
: Generates the POM file for Maven publication.publishMavenPublicationToMavenLocal
: Publishes to the local Maven repository.publishMavenPublicationToMavenRepository
: Publishes to a remote Maven repository.publish
: Aggregates all publishing tasks.
eclipseClasspath
: Generates the Eclipse classpath file.eclipseJdt
: Generates the Eclipse JDT settings.eclipseProject
: Generates the Eclipse project file.eclipse
: Aggregates all Eclipse tasks.
ideaModule
: Generates the IntelliJ IDEA module files.ideaProject
: Generates the IntelliJ IDEA project file.ideaWorkspace
: Generates the IntelliJ IDEA workspace file.idea
: Aggregates all IDEA tasks.
compileJava
: Compiles Java source files.processResources
: Processes resource files.classes
: Assembles the compiled classes.run
: Runs a Java application.- Sub-task:
run.main
: Specifies the main class to run. - Sub-task:
run.args
: Specifies command-line arguments.
- Sub-task: