SkillAgentSearch skills...

1JPM

Maven/Gradle alternative with a twist: its a single Java file! Edit it to configure your project.

Install / Use

/learn @Osiris-Team/1JPM
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

1JPM

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 or Groovy/DSL, your build file is Java code too.

To build your project, simply drag-and-drop the JPM.java file into your project, open a terminal and execute java JPM.java (Java 11 and above).

<details> <summary>Older Java and JDK notes</summary>
  • Java 8 to 10: javac JPM.java && java -cp . JPM
  • Earlier Java versions are not supported
  • Make sure you use a globally installed JDK (not JRE) with JAVA_HOME set
</details>

Good to know:

  • This repository functions as a template too
  • 1JPM is a Maven pom.xml generator, thus great IDE support by default
  • 1JPM includes some extra plugins to increase runtime safety and provide additional features out of the box
public class JPM {
    public static class ThisProject extends JPM.Project {
        public ThisProject() throws IOException, InterruptedException {
            this(null);
        }
        public ThisProject(List<String> args) throws IOException, InterruptedException {
            // Override default configurations
            this.groupId = "com.mycompany.myproject";
            this.artifactId = "my-project";
            this.version = "1.0.0";
            this.mainClass = "com.mycompany.myproject.MyMainClass";
            this.jarName = "my-project.jar";
            this.fatJarName = "my-project-with-dependencies.jar";

            // If there are duplicate dependencies with different versions force a specific version like so:
            //forceImplementation("org.apache.commons:commons-lang3:3.12.0");

            // Add dependencies
            implementation("org.apache.commons:commons-lang3:3.12.0");
            testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.3");

            // Add compiler arguments
            addCompilerArg("-Xlint:unchecked");
            addCompilerArg("-Xlint:deprecation");

            // Add additional plugins
            //JPM.plugins.add(PackagerPlugin.get); // or enable built-in ones
            //putPlugin("org.codehaus.mojo:exec-maven-plugin:1.6.0", d -> {
            //    d.putConfiguration("mainClass", this.mainClass);
            //});

            // Execute build
            if(args != null){
                generatePom();
                if(!args.contains("skipMaven"))
                    JPM.executeMaven("clean", "package");//, "-DskipTests"); 
                // or JPM.executeMaven(args); if you prefer the CLI, like "java JPM.java clean package"
            }
        }
    }

    public static class ThirdPartyPlugins extends JPM.Plugins{
        // Add third party plugins below, find them here: https://github.com/topics/1jpm-plugin?o=desc&s=updated
        // (If you want to develop a plugin take a look at "JPM.AssemblyPlugin" class further below to get started)
    }

    // 1JPM version 3.0.3 by Osiris-Team: https://github.com/Osiris-Team/1JPM
    // To upgrade JPM, replace everything below with its newer version
}

Above you can see the example configuration which runs the clean package tasks. This compiles and creates a jar file from your code, and additionally creates the sources, javadoc and with-dependencies jars.

Additional goodies and FAQ

☕ Execute your custom Java code at compile time

Write your build scripts directly in Java! A simple usage example is adding a timestamp/version of the current build somewhere inside your actual application. Your application code in Main.java then looks like this:

<details> <summary></summary>
//...
            add(new H6("Version " + LocalDateTime.ofInstant(Instant.ofEpochMilli(/*CURRENT_MILLIS_AT_JPM_BUILD*/1747573889290L), ZoneId.systemDefault()).toLocalDate().toString()));
//...

And inside the JPM class you add something like this:

        // Replaces/Updates the current timestamp in the main class, looks like this: /*CURRENT_MILLIS_AT_JPM_BUILD*/1747573889290L
        var srcFolder = new File(System.getProperty("user.dir") + "/src/main/java");
        var mainFile = new File(srcFolder +"/"+ mainClass.replace(".", "/").replace("Main", "Main.java"));
        var s = Files.readString(mainFile.toPath());
        Files.writeString(mainFile.toPath(), s.replaceFirst("/\\*CURRENT_MILLIS_AT_JPM_BUILD\\*/\\d+L",
                "/*CURRENT_MILLIS_AT_JPM_BUILD*/"+System.currentTimeMillis()+"L"));
</details>

🧩 1JPM helps porting your multi-module project

Add JPM.java to your root project directory and add JPM.portChildProjects(); before building. This is going to download and copy the latest JPM.java file into all child projects it can find in this directory, and also run it to generate an initial pom.xml for that child project. The child projects name will be the same as its directory name.

<details> <summary></summary>

A child project is detected if a src/main/java folder structure exists, and the parent folder of src/ is then used as child project root.
Note that a child project is expected to be directly inside a subdirectory of this project.

Now project.isAutoParentsAndChildren will work properly, since all needed pom.xml files should exist.

Do you also need something like global variables across those projects? Then the String val = $("key"); function might be of help to you, since it can easily retrieve values for props defined in the nearest JPM.properties file.

</details>

🧭 1JPM automatically resolves parent and child projects

See project.isAutoParentsAndChildren. If true updates current pom, all parent and all child pom.xml files with the respective parent details, adding seamless multi-module/project support.

<details> <summary></summary>

This expects that the parent pom is always inside the parent directory, otherwise a performant search is not possible since the entire disk would need to be checked.

</details>

🧊 1JPM can create native executables

GraalVM must be installed and Visual Studio 2022, then simply add the following before building.

            plugins.add(NativeImagePlugin.get);

            // Execute build with GraalVM with JAVA_HOME updated
            if(args != null){
                generatePom();
                if(!args.contains("skipMaven"))
                    JPM.executeMaven(null, pb -> {
                        pb.environment().put("JAVA_HOME", "C:\\Users\\YOUR_USERNAME\\YOUR_PATH\\graalvm-jdk-24.0.2");
                    }, "package", "-DskipTests");
                // or JPM.executeMaven(args); if you prefer the CLI, like "java JPM.java clean package"
            }

The NativeImagePlugin in 1JPM is designed to integrate GraalVM's native image building capabilities into your Java project with minimal configuration. By default, it now does the following:

<details> <summary></summary>
  1. Image Generation: It builds a native executable from your Java application using GraalVM. The generated executable is placed in the target directory.

  2. Default Configuration:

    • imageName: Defaults to the project's artifactId.
    • mainClass: Automatically determined from the project’s main class configuration.
    • build-native execution: Compiles the project into a native image during the package phase.
    • test-native execution: Compiles and runs tests as native images during the test phase.
  3. Basic Options: The plugin can be further configured with options like verbose output, additional buildArgs, or enabling debug information, but these are not set by default.

This setup allows you to seamlessly build native executables with GraalVM, leveraging its performance benefits and ahead-of-time (AOT) compilation, directly from your Maven build process.

For more details see this GraalVM article.

</details>

📦 1JPM can create native installers

Simply add JPM.plugins.add(PackagerPlugin.get); before building. With the default configuration, the PackagerPlugin in 1JPM:

<details> <summary></summary>
  • Bundles a JRE with the application package, ensuring the packaged application is self-contained and can run on any system without requiring an external JRE.
  • Uses the project's main class as the entry point for the application, which is automatically set based on the project's configuration.
  • Generates a basic executable package without additional platform-specific settings, tarballs, or zipballs.
  • Creates an installer for the application by default for the current operating system.

This default setup is ideal for quickly packaging a Java application into a distributable format that includes everything needed to run the app. For more details see JavaPackager on GitHub.

</details>

📚 1JPM is Maven based

1JPM is a Maven pom.xml generator and includes some extra plugins to increase runtime safety and provide additional features out of the box.

<details> <summary></summary>

We use Maven since the complexity as a fully independent build tool (see version 1.0.3) was too high for a single file. Besides, this gives us access to more features, a rich and mature plugin ecosystem, as well as great IDE compatibility. 1JPM will take care of generating the pom.xml, downloading the Maven-Wrapper, and then executing Maven as you can see above`.

</details>

🔌 1JPM has plugins

A 1JPM plugin is basically a wrapper around a Maven plugin (its xml), providing easy access to its features, but can also be anything else to make building easier. These third-party plugins can be added simply by appending their Java code inside the ThirdPartyPlu

Related Skills

View on GitHub
GitHub Stars225
CategoryProject
Updated5d ago
Forks5

Languages

Java

Security Score

100/100

Audited on Apr 2, 2026

No findings