{"id":25777025,"url":"https://github.com/Osiris-Team/1JPM","last_synced_at":"2025-02-27T06:07:06.488Z","repository":{"id":247416068,"uuid":"825475391","full_name":"Osiris-Team/1JPM","owner":"Osiris-Team","description":"1 Java Project Manager, is a Maven/Gradle alternative with a twist. Its a single Java file itself, which should be edited by you to configure your project.","archived":false,"fork":false,"pushed_at":"2024-10-17T18:13:08.000Z","size":199,"stargazers_count":214,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-20T03:26:37.148Z","etag":null,"topics":["build-tool","dependecy-manager","project-management"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Osiris-Team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-07T22:03:27.000Z","updated_at":"2024-10-17T18:13:11.000Z","dependencies_parsed_at":"2024-10-20T16:18:35.970Z","dependency_job_id":null,"html_url":"https://github.com/Osiris-Team/1JPM","commit_stats":null,"previous_names":["osiris-team/1jpm"],"tags_count":15,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osiris-Team%2F1JPM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osiris-Team%2F1JPM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osiris-Team%2F1JPM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osiris-Team%2F1JPM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Osiris-Team","download_url":"https://codeload.github.com/Osiris-Team/1JPM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987435,"owners_count":19889335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build-tool","dependecy-manager","project-management"],"created_at":"2025-02-27T06:01:34.539Z","updated_at":"2025-02-27T06:07:06.480Z","avatar_url":"https://github.com/Osiris-Team.png","language":"Java","funding_links":["https://www.paypal.com/donate?hosted_button_id=JNXQCWF2TF9W4"],"categories":["构建工具"],"sub_categories":[],"readme":"# 1JPM\n1 Java Project Manager (1JPM), is a Maven/Gradle alternative with a twist.\nIt's a single Java file itself, which should be edited by you to configure your project.\nMeaning instead of writing XML or Groovy/DSL, your build file is Java code too.\n\n**To build your project, simply [drag-and-drop the JPM.java file](./src/main/java/com/mycompany/myproject/JPM.java) \ninto your project, open a terminal and execute `java JPM.java` (Java 11 and above).**\n\n\u003cdetails\u003e\n\u003csummary\u003eOlder Java and JDK notes\u003c/summary\u003e\n\n- Java 8 to 10:  `javac JPM.java \u0026\u0026 java -cp . JPM`\n- Earlier Java versions are not supported\n- Make sure you use a [globally installed JDK](https://adoptium.net/temurin/releases/?os=windows\u0026package=jdk)\n(not JRE) with JAVA_HOME set\n\u003c/details\u003e\n\n\nGood to know:\n- This repository functions as a template too\n- 1JPM is Maven based, thus great IDE support by default\n- 1JPM includes some extra plugins to increase runtime safety and provide additional features out of the box\n\n```java\npublic class JPM {\n    public static class ThisProject extends JPM.Project {\n        public ThisProject() throws IOException, InterruptedException {\n            this(null);\n        }\n        public ThisProject(List\u003cString\u003e args) throws IOException, InterruptedException {\n            // Override default configurations\n            this.groupId = \"com.mycompany.myproject\";\n            this.artifactId = \"my-project\";\n            this.version = \"1.0.0\";\n            this.mainClass = \"com.mycompany.myproject.MyMainClass\";\n            this.jarName = \"my-project.jar\";\n            this.fatJarName = \"my-project-with-dependencies.jar\";\n\n            // If there are duplicate dependencies with different versions force a specific version like so:\n            //forceImplementation(\"org.apache.commons:commons-lang3:3.12.0\");\n\n            // Add dependencies\n            implementation(\"org.apache.commons:commons-lang3:3.12.0\");\n            testImplementation(\"org.junit.jupiter:junit-jupiter-api:5.10.3\");\n\n            // Add compiler arguments\n            addCompilerArg(\"-Xlint:unchecked\");\n            addCompilerArg(\"-Xlint:deprecation\");\n\n            // Add additional plugins\n            //putPlugin(\"org.codehaus.mojo:exec-maven-plugin:1.6.0\", d -\u003e {\n            //    d.putConfiguration(\"mainClass\", this.mainClass);\n            //});\n\n            // Execute build\n            if(args != null){\n                generatePom();\n                if(!args.contains(\"skipMaven\"))\n                    JPM.executeMaven(\"clean\", \"package\");//, \"-DskipTests\"); \n                // or JPM.executeMaven(args); if you prefer the CLI, like \"java JPM.java clean package\"\n            }\n        }\n    }\n\n    public static class ThirdPartyPlugins extends JPM.Plugins{\n        // Add third party plugins below, find them here: https://github.com/topics/1jpm-plugin?o=desc\u0026s=updated\n        // (If you want to develop a plugin take a look at \"JPM.AssemblyPlugin\" class further below to get started)\n    }\n\n    // 1JPM version 3.0.3 by Osiris-Team: https://github.com/Osiris-Team/1JPM\n    // To upgrade JPM, replace everything below with its newer version\n}\n```\n\nAbove you can see the example configuration which runs the `clean package` tasks.\nThis compiles and creates a jar file from your code, and additionally creates the sources,\njavadoc and with-dependencies jars.\n\n### Additional goodies and FAQ\n\n#### 1JPM automatically resolves parent and child projects\n\u003cdetails\u003e\n\u003csummary\u003e\u003c/summary\u003e\n\nSee `project.isAutoParentsAndChildren`.\nIf true updates current pom, all parent and all child pom.xml\nfiles with the respective parent details, adding seamless multi-module/project support.\n\nThis expects that the parent pom is always inside the parent directory,\notherwise a performant search is not possible since the entire disk would need to be checked.\n\u003c/details\u003e\n\n#### 1JPM helps porting your multi-module project\n\u003cdetails\u003e\n\u003csummary\u003e\u003c/summary\u003e\n\nAdd JPM.java to your root project directory and add `JPM.portChildProjects();` before building.\nThis is going to download and copy the latest JPM.java file into all child projects it can find\nin this directory, and also run it to generate an initial pom.xml for that child project.\nThe child projects name will be the same as its directory name.\n\nA child project is detected\nif a src/main/java folder structure exists, and the parent folder of src/ is then used as child project root.  \nNote that a child project is expected to be directly inside a subdirectory of this project.\n\nNow `project.isAutoParentsAndChildren` will work properly, since all needed pom.xml files should exist.\n\nDo you also need something like global variables across those projects? \nThen the `String val = $(\"key\");` function might be of help to you,\nsince it can easily retrieve values for props defined in the nearest JPM.properties file.\n\n\u003c/details\u003e\n\n#### 1JPM can create native executables\n\u003cdetails\u003e\n\u003csummary\u003e\u003c/summary\u003e\n\nGraalVM must be installed, then simply add `JPM.plugins.add(NativeImagePlugin.get);` before building.\n\nThe `NativeImagePlugin` in 1JPM is designed to integrate GraalVM's native image building capabilities into your Java project with minimal configuration. By default, it does the following:\n\n1. **Image Generation**: It builds a native executable from your Java application using GraalVM. The generated executable is placed in the `target` directory.\n\n2. **Default Configuration**:\n    - **`imageName`**: Defaults to the project's `artifactId`.\n    - **`mainClass`**: Automatically determined from the project’s main class configuration.\n    - **`build-native` execution**: Compiles the project into a native image during the `package` phase.\n    - **`test-native` execution**: Compiles and runs tests as native images during the `test` phase.\n\n3. **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.\n\nThis 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.\n\nFor more details see [this GraalVM article](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html).\n\n\u003c/details\u003e\n\n#### 1JPM can create native installers\n\u003cdetails\u003e\n\u003csummary\u003e\u003c/summary\u003e\n\nSimply add `JPM.plugins.add(PackagerPlugin.get);` before building.\nWith the default configuration, the `PackagerPlugin` in 1JPM:\n\n- **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.\n- **Uses the project's main class** as the entry point for the application, which is automatically set based on the project's configuration.\n- **Generates a basic executable package** without additional platform-specific settings, tarballs, or zipballs.\n- **Creates an installer** for the application by default for the current operating system.\n\nThis default setup is ideal for quickly packaging a Java application into a distributable format that includes everything needed to run the app.\nFor more details see [JavaPackager on GitHub](https://github.com/fvarrui/JavaPackager).\n\n\u003c/details\u003e\n\n#### 1JPM is Maven based\n\u003cdetails\u003e\n\u003csummary\u003e\u003c/summary\u003e\n\nNote that 1JPM is now using **Maven under the hood**, since the complexity as a fully independent build tool\n(see version [1.0.3](https://github.com/Osiris-Team/1JPM/blob/1.0.3/src/main/java/JPM.java)) 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`.\n\n\u003c/details\u003e\n\n#### 1JPM has plugins\n\u003cdetails\u003e\n\u003csummary\u003e\u003c/summary\u003e\n\nA 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.\nThese third-party plugins can be added simply by appending their Java code inside the ThirdPartyPlugins class.\nYou can find a list here at [#1jpm-plugin](https://github.com/topics/1jpm-plugin?o=desc\u0026s=updated).\n(these must be written in Java 8 and not use external dependencies).\n\u003c/details\u003e\n\n\n#### 1JPM saves you time\n\u003cdetails\u003e\n\u003csummary\u003e\u003c/summary\u003e\n\nHow many lines of relevant build code do we save compared to Maven?\n- 1JPM: 128 lines (see [here](https://github.com/Osiris-Team/AutoPlug-Client/blob/bd580033dea4f0cb7399496e9a01bf8047fb5d88/src/main/java/JPM.java))\n- Maven: 391 lines (see [here](https://github.com/Osiris-Team/AutoPlug-Client/blob/bd580033dea4f0cb7399496e9a01bf8047fb5d88/pom.xml))\n\nThus we write the same config with **263 lines less** code (which is a **3x** saving) when using 1JPM!\n\u003c/details\u003e\n\n\n#### How can I modify the generated pom.xml file? How to use the XML class?\n\u003cdetails\u003e\n\u003csummary\u003e\u003c/summary\u003e\n\nInside your ThisProject class you can override the toXML() like so:\n```java\n@java.lang.Override\npublic com.mycompany.core.JPM.XML toXML() {\n   XML pom = super.toXML(); // Returns \u003cproject\u003e element that is fully populated based on ThisProject settings\n   \n   // Modify here, the example below adds a \u003cresource\u003e \n   // (which will ultimately add non .java files to the output jar too, just an example)\n   XML res = new XML(\"resource\");\n   res.put(\"directory\", \"src/main/java\");\n   res.put(\"filtering\", \"false\");\n   res.put(\"includes include\", \"**/*\");\n   res.put(\"excludes exclude\", \"**/*.java\");\n\n   pom.add(\"build resources\", res);\n   return pom;\n}\n```\n\u003c/details\u003e\n\n#### 1JPM is able to auto-update itself\n\n\n## Why a single file?\n\n#### Pros\n- IDEs should provide decent auto-complete when JPM.java is in the project root (where your pom.xml/build.gradle)\nusually is.\n- To access all your IDEs fancy features, you can also add JPM.java to ./src/main/java.\nThis also grants the rest of your project easy access to its data, like your projects version for example.\nJust make sure that your working dir is still at ./ when executing tasks.\n- Simple drag and drop installation.\n- Direct access to the source of 1JPM and what happens under the hood for those who like exploring or better\nunderstanding how something works, which can be helpful if issues arise.\n\n#### Cons / Todo\n- Developing plugins is tricky (if you want them to be more complex) since you can't really use third-party dependencies at the moment.\nA workaround for this would be developing a task like \"minifyProject\" which would merge a complete project into 1 line of code,\n\n## Tipps\n- You can use ChatGTP (or another LLM) to easily port your current Maven/Gradle based project over to 1JPM,\nby sending it the above example `ThisProject` class and your current build details files (pom.xml/build.gradle),\nthen prompting it something like: \"Port my current Maven/Gradle project to the JPM build tool, by modifing the ThisProject class accordingly\".\nIf you have additional plugins also send it an example plugin from within the JPM class.\n\n## Funding\nI am actively maintaining this repository, publishing new releases and working \non its codebase for free, so if this project benefits you and/or your company consider \ndonating a monthly amount you seem fit. Thank you!\n\n\u003ca href=\"https://www.paypal.com/donate?hosted_button_id=JNXQCWF2TF9W4\"\u003e\u003cimg src=\"https://github.com/andreostrovsky/donate-with-paypal/raw/master/blue.svg\" height=\"40\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOsiris-Team%2F1JPM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOsiris-Team%2F1JPM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOsiris-Team%2F1JPM/lists"}