Bach.java: Lightweight Java Build Tool for Modular Projects
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
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 | 10.5446/47469 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
FOSDEM 2020334 / 490
4
7
9
10
14
15
16
25
26
29
31
33
34
35
37
40
41
42
43
45
46
47
50
51
52
53
54
58
60
64
65
66
67
70
71
72
74
75
76
77
78
82
83
84
86
89
90
93
94
95
96
98
100
101
105
106
109
110
116
118
123
124
130
135
137
141
142
144
146
151
154
157
159
164
166
167
169
172
174
178
182
184
185
186
187
189
190
191
192
193
194
195
200
202
203
204
205
206
207
208
211
212
214
218
222
225
228
230
232
233
235
236
240
242
244
249
250
251
253
254
258
261
262
266
267
268
271
273
274
275
278
280
281
282
283
284
285
286
288
289
290
291
293
295
296
297
298
301
302
303
305
306
307
310
311
315
317
318
319
328
333
350
353
354
356
359
360
361
370
372
373
374
375
379
380
381
383
385
386
387
388
391
393
394
395
397
398
399
401
409
410
411
414
420
421
422
423
424
425
427
429
430
434
438
439
444
449
450
454
457
458
459
460
461
464
465
466
468
469
470
471
472
480
484
486
487
489
490
00:00
Java appletBuildingModul <Datentyp>Computer animation
00:20
Java appletVirtual machineComputerMathematicianBuildingJava appletProjective planeProcess (computing)Computer animation
00:43
Virtual machineDesign of experimentsMathematicianComputerModul <Datentyp>BuildingJava appletBeer steinExecution unitApache MavenCausalityAuthorizationMereologyInternetworkingWebsiteProjective planeLibrary (computing)NeuroinformatikProcess (computing)Computer animation
01:17
Data modelDemo (music)Library (computing)BuildingDataflowCompilerComputer animation
01:58
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
02:57
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
05:06
Demo (music)Java appletDrum memoryProjective planeMultiplication signComputer fileJava appletWordState of matterMaxima and minimaProcess (computing)Computer animation
05:50
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
11:16
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
16:42
Convex hullJava appletModulo (jargon)Module (mathematics)Open sourcePoint cloudFacebookComputer animation
Transcript: English(auto-generated)
00:06
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
00:27
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.
00:49
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
01:01
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.
01:22
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
01:43
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.
02:00
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
02:29
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.
02:43
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.
03:04
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
03:23
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.
03:48
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.
04:05
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.
04:20
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,
04:47
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.
05:02
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.
05:20
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.
05:45
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.
06:03
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.
06:21
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.
06:45
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.
07:04
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.
07:22
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,
07:45
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.
08:03
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.
08:27
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.
08:45
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.
09:09
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.
09:20
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.
09:47
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.
10:06
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.
10:25
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.
10:41
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.
11:01
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.
11:26
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.
11:42
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.
12:03
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.
12:22
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.
12:42
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.
13:11
Now let's initialize Bach into this folder and not use the on the fly entry point.
13:20
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.
13:41
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.
14:00
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.
14:20
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.
14:47
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.
15:05
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.
15:22
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.
15:41
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.
16:04
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.
16:27
And we have a modeler Java 11 project. Kudos to Gerrit for providing this little project here. Thanks for listening.
Recommendations
Series of 4 media