7 ms·
1JPM: A Maven/Gradle alternative in a single Java file
- invalidname 2y agoHow is it different from: https://rife2.com/bld https://rife2.com/bld
- spullara 2y agoYou don't need to install anything. Just include the Java file in your repository. "Install bld through Homebrew, SDKMAN!, JBang, ..."
- the_af 2y agoThose are just alternatives. Literally the first option they list is to just download the jar and run it manually, because this tool truly doesn't need any installation.
- devman0 2y agoI haven't been in the java ecosystem in a while, but when I was using Maven you could just download the portable version and run it, and towards the tail end you could just include a simple mvn build shim that would pull down the correct version of maven and run it in a portable way (I think this was an idea borrowed from Gradle). Maven itself, afterall, was nothing more than a java application (as was Ant before it).
- pandemic_region 2y ago> bld was created because we're not really interested in build tools. We use them because we have to, but we'd rather just get on with coding the real stuff. no interest in build tools, so let's create our own. Baffling.
- the_af 2y agoNever heard of bld before, but my read is that they were overwhelmed by the complexity of existing tools, and wanted one with minimal frills that doesn't get in the way and which looks like app code (as opposed to using a declarative language), so they wrote one. I suppose they wanted to "get it over with"... whether this is a pipe dream or not remains to be seen ;)
- Tainnor 2y agoBuild tools are complex because builds are complex. Of course, if you create a bespoke tool for your specific use case and then a bunch of other people use it but it doesn't really gain widespread adoption, you can keep stuff simple. I'm not saying that there's not accidental complexity in current build tools and that a new build tool couldn't strike the balance better, but a rarely used build tool being simple doesn't really say much (and this much is true for almost any kind of software).
- the_af 2y agoI'm not disputing anything you say, but my comment was aimed at explaining why someone who doesn't like dealing with build tools would want to write one. I don't want to have to defend their choice or explain why build tools are often complex and cumbersome.
- dvzk 2y agoSadly there's tons of code-based Java build tools, but possibly zero concise (toml/yaml- like) declarative build tools. If you're currently using Groovy or Kotlin scripts for building Java projects however, then Java build scripts are appealing.
- smallerfish 2y agoI mostly like the Kotlin flavor of Gradle, but it still has some relatively simple workflows for which you need to deeply understand the execution model of Gradle. The ideal build tool would just work intuitively - i.e. would be geared towards developers rather than build tool nerds. For example, I wanted a standalone database migration task that wouldn't be run by default. The magic for that is "doLast", which I don't think describes what it's actually doing particularly well. tasks.register("db-migrate", DatabaseSetup::class) { doLast { println("Now migrating") migrate() jooqGenerate() } }
- Osiris-Team 2y agoIts not really different. Except that bld seems to only support Java 17+, whereass 1JPM support Java 8+ and there is still a lot of Java 8 projects out there I guess. Another difference is also that 1JPM is a single file, which has its advantages and disantwages, checkout the README for more details.
- spullara 2y agoAs much as I hate adding more build tools to the Java ecosystem this one is pretty interesting since it is entirely Java based and version controllable without any additional dependencies to install. Obviously this won't solve all build problems but its simplicity is attractive. (my hate for new build tools https://javarants.com/why-your-new-jvm-build-tool-is-making-things-worse-aka-use-maven-to-execute-your-build-a22ef66baa74 https://javarants.com/why-your-new-jvm-build-tool-is-making-...)
- from-nibly 2y agoMy fear is upgrading/maintaining this long term. At my current company we have Gradle build files from 10 years ago and they are really fragile.
- vips7L 2y agoThat is just Gradle. Maven works every single time.
- ethanol 2y agoTen years? Try one year. I've had massive problems upgrading Gradle between consecutive major versions despite always trying to stick to the rules (as I understand them) and never using deprecated or experimental features. Maven simply doesn't have these problems. Search for Gradle discussions on HN if you're interested, the rough consensus of this site (if there is such a thing) seems to confirm my experience.
- brnt 2y agoFunny, I'd've expected the opposite in the Java ecosystem. As someone entirely outside of it: why would one then use Gradle? Haven't seen a single positive post here yet.
- vips7L 2y agoGradle has faster builds due to the build daemon it uses and it has a better CLI interface. Starting a new project is just: gradle init. Some people use it just because XML == bad too.
- abeppu 2y agoSo given that its intended mode of use is to be copied into another project and modified ... when would this maven build file in it be used? Also, I don't see that the dependencies (e.g. their `jlib`) actually get used. https://github.com/Osiris-Team/1JPM/blob/main/pom.xml https://github.com/Osiris-Team/1JPM/blob/main/pom.xml
- Osiris-Team 2y agoRight now I am using Maven to build 1JPM, or more accurately be able to do things in my IDE. You won't need that pom.xml though since 1JPM is only dependent on Java 8.
- jareds 2y agoThis would have interested me before wrappers for Maven and Gradle became common. Now that you can check in wrappers and easily upgrade the build tool version I don't see this being worth while for general use. I could see it being useful in situations where you needed full code auditability of everything involved in the build process but I've never run into that requirement in my work.
- brnt 2y agoWhat's a popular Maven wrapper?
- svieira 2y agoMaven: https://maven.apache.org/wrapper/ https://maven.apache.org/wrapper/
- Osiris-Team 2y agoYeah, some kind people over Reddit also shared some nice repositiories like this one: https://github.com/takari/polyglot-maven https://github.com/takari/polyglot-maven Which would have been great if I found it earlier, since it allows you to use maven but write Java. The only edge 1JPM has compared to that project is that auto-complete and even more advanced features of your IDE work with it, since you can also move your JPM.java file into ./src/main/java.
- systemerror 2y agoI hate reading documentation too.
- Osiris-Team 2y agoAh a fellow tab-autocomplete power user.
- sgammon 2y agoThis is cool. Even if we can't use it, it's cool to see innovation in Java build tools.
- Osiris-Team 2y agoYeah, however once there are IntelliJ IDEA and VSCode plugins for 1JPM and I actually add some test cases, it should be usable.
- mohaine 2y agoIsn't this the exact opposite of what you want security wise? To even read the most basic project metadata (project name, version, deps, ... ), you have to run arbitrary in project code. So you have to do a code review of the project file before you can even open the project in your IDE. Programmatic project scanning is right off the list.
- mvc 2y agoDoing this does not preclude publishing that kind of metadata as part of the build/deploy process.
- andylynch 2y agoGradle is no different here. Ditto many other build tool.
- krzyk 2y agoBut maven does not.
- stefs 2y agoyou mean because it's xml instead of executable code?
- krzyk 2y agoNo, because it was designed that way - declarative. You can have xml with code-like-structures, e.g. Ant
- oftenwrong 2y agoMaven plugins and extensions can execute arbitrary code, so you should still exercise care when running an untrusted maven project.
- packetlost 2y agoAt some level of complexity/edge-case-ey-ness you just need arbitrary execution to get things done. At some point you need to accept that that if you're pulling in a dependency, you trust the authors of that code enough to execute their code. That being said, getting project version, deps, etc. should be statically available for packages, but being computed from source isn't the worst thing IMO, though it's not what I would go with.
- whartung 2y agoI like the clever use of the "java prog.java" style. I don't know how many folks know, although its been there for a bit, that you no longer have to specifically compile single file java programs. You can just run them with with "java prog.java". (Honestly, I haven't used the technique myself, still old school -- even with silly small x.java tests and such. Muscle memory and all that.)
- grishka 2y agoI do it a lot. These single-file programs can be called Java scripts when run without compilation.
- apantel 2y agoI wonder what could be done with Java script…
- bionsystem 2y agoSounds like a name that could have some success. Given that the logo for Java is a cup of coffee, maybe we could also call it "Coffee script".
- mbreese 2y agoCan you add a shebang line and have it truly be a script? I do self executing JARs with a bash stub/header all the time, but haven’t tried with this.
- grishka 2y agoSadly you can't, Java doesn't support comments starting with # $ ./shebang.java ./shebang.java:1: error: illegal character: '#' #!/usr/bin/java ^ ./shebang.java:1: error: class, interface, enum, or record expected #!/usr/bin/java ^ 2 errors error: compilation failed Self-executable jars though, that's an interesting idea. No reason why it can't work, zip archives are read from the end, you can put anything in the beginning, including "#!/usr/bin/java -jar"
- bokchoi 2y agoI remember seeing a single file "build.java" from Cliff Click a while ago. I wonder if he's still using that technique. It took a while to find an example: https://github.com/edwardw/high-scale-java-lib/blob/master/build.java https://github.com/edwardw/high-scale-java-lib/blob/master/b...
- Osiris-Team 2y agoWow 14 years ago! Thats great! Those variable names are madness though haha. Or a single letter class is also pretty wild.
- hu3 2y agoI'm fascinated by one file solutions. Anyone have more examples?
- deleted 2y ago[deleted]
- bionsystem 2y agoaappleby/hancho on github (a build system in python) was discussed here some time ago
- twic 2y agoIt doesn't handle transitive dependencies. So it's only a "Maven/Gradle alternative" to the extent that you don't need those. Enjoy!
- SOLAR_FIELDS 2y agoAfter having worked with Gradle for many years, I think there is a lot packed into this statement: > 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. Gradle can do an insane amount of things. I would be surprised if this tool is capable of even 5% what Gradle can do. That being said, I actually see this as a feature. I think Gradle would actually be better if it could only do 10% of what it currently does. As is it’s so complex and powerful it’s tempting to pack all of your build logic into some impossible to understand and maintain Gradle configuration. Having a pure standalone Java file that people who are familiar with Java can work with seamlessly and is easily integrated with existing test suites is probably better in the long run. I’d rather see the “cruft” of build tooling lifted into a higher level of abstraction than the quasi DSL that is Gradle - IMO it’s too similar yet different to Java/Groovy/Scala that it’s too tempting to create an unmaintainable mess otherwise.
- chii 2y agoOr do some work to rid yourself of the logic in the build. Fit the build process into the build tool, rather than try to contort the build tool to suit the project. After all, it's unlikely that the project is such a special snowflake that it needs custom build steps, rather than just rely on the standard build steps provided in maven.
- twic 2y agoIt's not at all unlikely. Most large projects i've worked on have need some element of custom building. Generation of files, compiling native code, multiple separate test suites, etc. The Gradle developers didn't just add that flexibility because they felt like it, there's a genuine need that Maven does not meet.
- grishka 2y agoTo those who say that it's not a good idea to use a full programming language for your build scripts. Gradle uses "a full programming language" and I hate it but I have to use it for Android projects. Debugging Gradle problems is as fun as you'd imagine. There's a lot of dark matter in your build scripts that you don't see but that influences what happens. And because Android tooling is a clusterfuck ever since the demise of Eclipse+ADT, any change you make to your build process runs the risk of the entire thing exploding in your face. This one is at least fully predictable, self-contained and doesn't randomly download 150 MB of crap when you're on a slow coffee shop wifi. I'm gonna try it sometime.
- lmm 2y ago> Gradle uses "a full programming language" and I hate it Yep, that's exactly why you're much better off with Maven. Last I knew it was still possible to build Android apps with Maven, even if it's not the primary/recommended way.
- kaba0 2y agoGradle uses a programming language to create a static build graph that can be analyzed and efficiently executed. I agree that gradle is not the most user-friendly software out there, but I can only think of bazel that would be up for the task of building such a complex project as android, so it’s also a testament to its strength.
- Osiris-Team 2y agoHappy to hear that! 1JPM is still pretty new and I expect there to be bugs, so if you have some free time and are interested in making this something usable feel free to contribute some day :)
- overtomanu 2y agoThere is also another similar tool for building projects with Java code https://jeka-dev.github.io/jeka/tutorials/build-projects/#example-with-flat-facade https://jeka-dev.github.io/jeka/tutorials/build-projects/#ex... https://jeka.dev/ https://jeka.dev/
- Osiris-Team 2y agoInteresting, I guess the focus there is more on scripting. For 1JPM the focus is more Maven/Gradle similarity with Java build file.
- noisy_boy 2y agoMaven has plugins for practically every conceivable use case - if I have to implement all that, this single Java file will become another giant file that will bring its own can of worms minus the advantages of the Maven ecosystem.
- nunobrito 2y agoYou can continue using Maven if that is your choice. I'm enjoying this approach. It can likely pull most of the Maven functionality needed for my (simple) projects.
- Osiris-Team 2y agoYeah I don't think there is much that can be done against this. Its a complex topic and simple solutions are basically just a dream. Worked on transitive dependencies, and let me tell you, the version of such a dependency can be literally anywhere.
- 2d8a875f-39a2-4 2y agobuild systems logging libraries application frameworks Every dev at some stage early in their career always thinks that they can create a better one.
- Osiris-Team 2y agoI think 1JPM is a wild idea and could be better in the future, but it's hard to compete with 20 years of development at release.
- afavour 2y agoAs someone who doesn't dabble with Java too often, this looks nice. I do cross-platform mobile work from time to time and whenever I pick up Android I end up bashing my head against the wall with all the Maven/Gradle stuff. I'm sure it's intuitive when you're using it a ton but it always feels overcomplicated to me.
- happymellon 2y ago> Maven/Gradle stuff. I'm sure it's intuitive when you're using it a ton Maven was okay, Gradle less so. It comes down to being opinionated or infinitely flexible, and being infinitely flexible means that Gradle can be infinitely complex if you have "one of those people" on your team. Gradle, in my opinion, was a bad move.
- Osiris-Team 2y agoThats what 1JPM is also trying to prevent a bit, by leveraging the rigid structure of Java, or more accurately by proving an API that tries to satisfy noobs and power users.
- happymellon 2y agoThat would be nice. Thanks!
- thiht 2y agoOh I expected to see a Java project with a single Java file inside, glad to see it’s nested in 3 folder levels. Java never disappoints
- Osiris-Team 2y agoHaha yes, if the IDE isn't happy, I'm not happy. But checkout the releases under github, there you can find the magical single JPM.java file you are looking for ;)
- thiht 2y agoNice, that’s refreshing!
- oftenwrong 2y agoYou can quite easily get by with the standard JDK tools (javac, jlink, etc) + a tool for fetching dependencies, such as https://github.com/coursier/coursier https://github.com/coursier/coursier or https://github.com/bowbahdoe/jresolve https://github.com/bowbahdoe/jresolve .
- exabrial 2y agoI love seeing small Java projects like this and I always enjoy reading through the code. On build tools: I don't actually mind Maven: I use a proper editor that can read and understand an XSD schema. But if it weren't for that I'd totally understand why people dislike it!
- tpoacher 2y agoAnd then there's me, still preferring make + @argfiles like a madman :p
- Osiris-Team 2y agoWell, thanks for reposting from Reddit! Got way more attention over here than there.