We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Bach.java: Lightweight Java Build Tool for Modular Projects

00:00

Formal Metadata

Title
Bach.java: Lightweight Java Build Tool for Modular Projects
Title of Series
Number of Parts
490
Author
License
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
I present "Bach.java" - a lightweight build tool for Java. Bach.java uses jshell/java to build modular Java projects. It supports a "zero installation" run mode, convention over configuration pragmatism, simple properties file to tweak defaults, and an API to build custom projects. In the spirit of Rémix Forax, who wrote: "No need to be a maven to be able to use a build tool", Bach.java is targeted to coders of small to mid-size Java projects, who want to focus on their ideas and modules instead of learning and taming a build tool.
33
35
Thumbnail
23:38
52
Thumbnail
30:38
53
Thumbnail
16:18
65
71
Thumbnail
14:24
72
Thumbnail
18:02
75
Thumbnail
19:35
101
Thumbnail
12:59
106
123
Thumbnail
25:58
146
Thumbnail
47:36
157
Thumbnail
51:32
166
172
Thumbnail
22:49
182
Thumbnail
25:44
186
Thumbnail
40:18
190
195
225
Thumbnail
23:41
273
281
284
Thumbnail
09:08
285
289
Thumbnail
26:03
290
297
Thumbnail
19:29
328
Thumbnail
24:11
379
Thumbnail
20:10
385
Thumbnail
28:37
393
Thumbnail
09:10
430
438
Java appletBuildingModul <Datentyp>Computer animation
Java appletVirtual machineComputerMathematicianBuildingJava appletProjective planeProcess (computing)Computer animation
Virtual machineDesign of experimentsMathematicianComputerModul <Datentyp>BuildingJava appletBeer steinExecution unitApache MavenCausalityAuthorizationMereologyInternetworkingWebsiteProjective planeLibrary (computing)NeuroinformatikProcess (computing)Computer animation
Data modelDemo (music)Library (computing)BuildingDataflowCompilerComputer animation
Social classComputer-generated imageryAssembly languageRun time (program lifecycle phase)Magneto-optical driveFormal languageComputer programmingCompilerJava appletDisassemblerComputer fileJava appletCartesian coordinate systemAttribute grammarCompilerMultiplication signRight angleOrder (biology)DataflowArmGraph (mathematics)Parameter (computer programming)Computer animation
MultiplicationBuildingJava appletLink (knot theory)Scripting languageSource codeService (economics)DemonCompilation albumJava appletDemo (music)Computer fileProjective planeMultiplication signWritingMultilaterationProcess (computing)Shape (magazine)Level (video gaming)Message passingForcing (mathematics)Formal languageRight angleoutputBitComputer animation
Demo (music)Java appletDrum memoryProjective planeMultiplication signComputer fileJava appletWordState of matterMaxima and minimaProcess (computing)Computer animation
Module (mathematics)Demo (music)Java appletSource codeBinary fileSerial portVolumeBuildingModulo (jargon)Social classInformationNetwork topologyComa BerenicesComputer fileConvex hullSoftware testingFunctional (mathematics)Process (computing)WordOrder (biology)Discrete element methodDirectory serviceScripting languageProjective planeSource codeLetterpress printingDensity of statesBuildingProfil (magazine)Module (mathematics)Content (media)Computing platformPower (physics)Ferry CorstenBus (computing)Parameter (computer programming)Computer configurationElectronic mailing listComputer fileGodEndliche ModelltheorieMultiplication signGraph coloringPoint (geometry)CodeLine (geometry)Open setCompilerGastropod shellNumberWebsiteEstimatorStaff (military)Row (database)Operating systemFunction (mathematics)Social classCross-platformWindowRepository (publishing)Java appletFormal language3 (number)BitDemo (music)MiniDiscInformationRight angleStapeldateiElectronic visual displayComputer animation
Java appletInformationNetwork topologyVolumeSerial portBuildingDemo (music)Modulo (jargon)Module (mathematics)GradientRevision controlSource codeMaxima and minimaModul <Datentyp>NumberGroup actionGastropod shellSingle-precision floating-point formatMixed realityServer (computing)Asynchronous Transfer ModeExecution unitSpacetimeFingerprintComputer fileMusical ensembleSoftware testingFunction (mathematics)Convex hullArithmetic meanTask (computing)AlgebraJava appletMedical imagingEndliche ModelltheorieRevision controlDirectory serviceProjective planeModulare ProgrammierungComputer fileModule (mathematics)Run-time systemExecution unitShared memoryBinary fileMetropolitan area networkData miningSource codeModule (mathematics)System callDisk read-and-write headHypermediaConfiguration spaceCoordinate systemMappingDemo (music)Multiplication signMiniDiscDatabaseCentralizer and normalizerSoftware testingGroup actionMathematicsComplete metric spaceCuboidPattern languageNumberGastropod shellProcess (computing)Rational numberPoint (geometry)Wave packetSpacetimeUniform resource locatorPresentation of a groupWebsiteWordCodec1 (number)Video gameComputer animation
Convex hullJava appletModulo (jargon)Module (mathematics)Open sourcePoint cloudFacebookComputer animation
Transcript: English(auto-generated)
Hello, my name is Christian Stein, your build tools are overkill, prepare to face another one, a light white one. I found a quote just today, I will show it, it's from Dijkstra, the tools we used
to have are profound and devious habits and therefore on our thinking abilities. So, what I want to show you today is a very light white tool to build Java projects.
I'm working for Mikomata, a company in Kassel, it's a great place to work. I'm also part of the OpenJDK committee, I'm the author in the project, that means
I can file issues on the internet side, and it's great. I'm part of the JUnit 5 team and also an Apache Maven committer, so I'm not bashing any other build tools, they're all great, I love them all, but for simple things they do a lot and they do too much.
And they do so much things that they can't keep up with the new release cadence very often, because sometimes they depend on external libraries like ASM and this will hold them back. So, we are used to have many build tools in the wild in the meanwhile and there's
a new build tool every year almost, but the JDK doesn't offer an old build tool for reasons. What does JDK offer us? Foundation tools.
Since JDK 1 we have at least the compiler and some others, a company, tools for creating documentation or packaging things up, and you see in the flow of time some other tools popped up, others were buried again, and soon we will have with Java 14 a packager
again to deploy our applications. And for me a build tool should just operate on those. If you do operate only on those, you're always up to date.
If you use them in the right order and put them in the right attributes and arguments, that's it. That's my definition of a build tool. So, let's paint it on a graph, the status quo.
See on the left the foundation tools on the right, the multi-purpose build tools all tend to evolve and grow and grow and not longer be a Java tool anymore. They all want to cook coffee or wash your cloth or whatever and then compile C
and whatnot. And in the middle there's make, there's scripts, almost the same, the make one is smarter, and I started my career with Ant and Ivy later. So, I always do think as the tools shape my thinking in the Ant way still.
And this is where I targeted back Java just to have it situated for you. So, the main goal is to not leave the realm of Java for the build tool.
I want my build tool, if I need to configure it, in the same realm, in the same language. That means I only want to write Java files as an input.
This excludes everything with X and Y and Z, whatever it may be. Every other language, I want to learn Java, I want to stay in Java, I like Java. So, why do you force me to other tools? And all the things in the background that might change, that might work, that do magic,
I don't want them. At that level, I don't need them. In small or dedicated projects that only want to build and run on Java.
So, here we go, demo time. And we start in the history, where we all wrote scripts, maybe. At least I did. Sound is on.
This is a project, by the way, I'm gonna build three times now. It's a no-hello-world project, but because it can't run hello-world, it can't say hello-world, it's just a module file. This is the smallest project you can build nowadays. But Java requires Java 11 as a minimum, because 9 is dead, 10 is dead, 11 is here to stay for some years.
So, let's kick it with this no-hello-world project. And everybody can read it, last row. Let's declare the source file, that's it, our no-hello-world project.
Let's create a DOS-based build script. Here you see the two calls, foundation tools, Java sees a compiler, has a target directory, has the new option used, the module source path. There is my module defined.
And it's in the source directory, then there's the module name encoded into the path. And, last but not least, we're gonna draw it into a .jar file for read-restribution, because it's a module, we want that one to be reused. Not really, because it does nothing, but your modules will sometimes.
So, what did we write? We have our project in the source folder, we have our build script, let's do Java C, let's Java C and .jar do the magic. No output is good, that means no error, those tools won't emit anything if everything is right.
And what do we get? A target directory with the compile classes and the .jar demo jar. Nothing fancy, but that's it. All I want to do in this simple project is compile and .jar. And we can also use the .jar command to describe our module.
This is the goal of the demo project. That's our Hello World. Now let's do this again and use a tool that was introduced, I think, in Java 9. It's Raychel. Because if I want to repeat this on another platform, and Java write once, run anywhere,
it doesn't work with DOS script batches on every platform. So, let's rewrite our project first, same as before, nothing more, nothing less. And now we just encode our build script in Raychel language.
Now we have four lines because there's a magic opener in the first line because I predefined some functions in a building script. It's like printing, it's available from Raychel if you look into the documentation. And it offers me a run function. And to the run function, I can pass in the name of the tool I want to run.
There's some internal tool providing lookup going on, and I provide paths like I do in Java if I would have programmed it. This one cares about translating forward slashes, backwards slashes and all the quirks of the operating systems.
And when I'm done, after Java C and Java, I do exit. The content is the same. So, what do we have? We have a build shell script and our project. We let the building script work. We source it into the Raychel session.
And because it runs from top down, if you see it up there, perfect timing. It opens the building script. It executes Java C, jar and then it exits.
And displays the command we just executed in a Windows-like fashion. And that's great. We see the same output on the disk. And here we go. That's all we had to do to see our hello world. What did we achieve? Platform independence.
And now I took this idea into a script which does more. It just analyzes your directory you're in. And it does the same basically as this Raychel script. It calls the JODK foundation tool in the right order with the right arguments.
So, here we go. Number three. Bach. We declare our project. That's it. And we don't need any local build script file. This is installation-less. Because we are in a working directory, any operating system will do.
And we use Raychel again as our main entry point. Because you can't source in not only local files but also remote files. That was too fast. I hit some key.
And you see it uses the bit key, the shortened URL Bach built. Which is nothing else as an expanded path to my GitHub repository. Where there is a Raychel file which says scan the actual directory for a module info file.
Look what's up there. Do the Java C and Java commands with the right arguments and that's it. It already knows that there's Java doc already and compiles for you the RP documentation just on the fly. And not only we have the Java call for the sources and the module but also for the Java doc.
So we are almost ready without doing any configuration of a build tool to deploy this to Maven Central. There's just missing the consumer pawn that others would need.
Pardon? There's no dependency in this module. There's no dependency. That's a demo project. But we do come to this topic later. And the dependencies. What a question. Yes, you see on the local disk I have some files more this time.
It's called up because Java doc created the entire documentation site. But in the end we can just show the build tool just built a modular Java project on the fly without any configuration.
But that's really not even a hello world demo. So let's pick it. How many times left? Five minutes? Eight minutes. Okay, so we skip two demos and go to almost the last one.
Which is I create a directory and I gonna scaffold a project from GitHub live into my box. Build it. We gonna have a look into the ingredients and then build it and run it. So let's call it invaders. Let's change into this invader directory. It's empty.
Now let's initialize Bach into this folder and not use the on the fly entry point.
How do we do this? We do this with racial HTTPS. It's just another URL to kick it off. I shortened it with Bitly. And it's called back in it. And if the connection works.
It does. It will just download a Java file and a share file. And that's it. And now I have a local. Let me put it to the upper end. A local command generated in my directory.
And I can scaffold like a project number five. This is from Garrett Hanzolo Space Fx. It's based on modules JDK 11 Java Fx 14. At least this one 15 is the next is already running.
It contains resources and medias and whatever. It's a full. It's a better head of work project than mine. This is the asset. These are the assets. And I took the freedom to add some modular testing because I'm in the J unit team to it. But you see there's no single maven or braided fly left. I just grabbed that out in my fork.
And the only command I need to to launch is this one. And this is smart enough to resolve the missing modules from a database I maintain in the public.
Which maps module names from the Java module system to the maven coordinates. If they are one to one mappings. And if they follow a specific and very strict naming patterns.
Like the artifact name starts with the complete group name. And that's it. We just built a runnable project. Which with documentation with Java file creation which with J unit tests for all modules.
And because Jlink was in my runtime system I didn't configure it. I had to opt out if I didn't want it. And no longer talking. Last minute is out. I just want to show the compiled version.
It's a launcher image. Man. And the launcher in the last command line. You see it. Nothing is hidden. It has a bin directory. And this is almost the end of this presentation.
And we have a modeler Java 11 project. Kudos to Gerrit for providing this little project here. Thanks for listening.