Beyond the "RUN" button



Build systems for the Java language



 ~ # whoami

Fulvio Meden


Developer @ eMaze Networks
 Student @ UniTS (information engineering)

coding with an ide


A small project:
 

coding with an ide

add a class...


coding with an ide

Add some code...


coding with an ide

and a main..


coding with an ide

then? RUN.


coding with an ide

A big project:

coding with an ide

add a class...

coding with an ide

Add some code...

coding with an ide

and a main..

coding with an ide

then? RUN.

coding with an ide






Easy, right?



But what's the magic beyond "run"?

how would i do it without the ide?


plain ol' command line:


caligin@theleth:~/projects$ javac Hello.java Main.java

how would i do it without the ide?


and for a bigger project:

caligin@theleth:~/projects$ javac org/anima/alma/AlmaFacade.java org/anima/alma/AnalysisDto.java org/anima/alma/LogDto.java org/anima/alma/AnalysisMetadataDto.java org/anima/alma/DefaultAlmaFacade.java org/anima/alma/EvaluationRequest.java org/anima/alma/LogAndMetadataDto.java org/anima/alma/configuration/Initializer.java org/anima/alma/evaluation/AnalysisExecutor.java org/anima/alma/evaluation/EvaluationMetadata.java org/anima/alma/evaluation/EvaluationSnapshot.java org/anima/alma/evaluation/InMemoryEvaluationRepository.java  org/anima/alma/evaluation/ResultPageRequest.java org/anima/alma/evaluation/TableSchema.java org/anima/alma/evaluation/DefaultAnalysisExecutor.java org/anima/alma/evaluation/EvaluationRepository.java org/anima/alma/evaluation/EvaluationStatus.java org/anima/alma/evaluation/PluckTableName.java org/anima/alma/evaluation/SoutAsResultsWriter.java   ...

how would i do it without the ide?


that's really not going to scale.


But the IDE is an automated tool, it's ok for it to just call javac with the full list of classes in my project.


Isn't it?

how would i do it without the ide?



Yes. But in most cases, the build features are provided via integration with an underlying Build Automation Tool


(or Build System, for friends.)

build system


A definition:


A build system is a tool for automating not only compilation of source code, but also a wide variety of tasks related to the "source to artifact" phase of software development.
----- me

a step back



Ok, that's almost interesting.
But actually, I wasn't even curious.

Why should I ever bother, if in the end the IDE actually does the dirty work for me?

do it manually




caligin@theleth:~/projects$ javac Hello.java Main.java

do it MANUALLY


and for a bigger project: 
caligin@theleth:~/projects$ javac org/anima/alma/AlmaFacade.java org/anima/alma/AnalysisDto.java org/anima/alma/LogDto.java org/anima/alma/AnalysisMetadataDto.java org/anima/alma/DefaultAlmaFacade.java org/anima/alma/EvaluationRequest.java org/anima/alma/LogAndMetadataDto.java org/anima/alma/configuration/Initializer.java org/anima/alma/evaluation/AnalysisExecutor.java org/anima/alma/evaluation/EvaluationMetadata.java org/anima/alma/evaluation/EvaluationSnapshot.java org/anima/alma/evaluation/InMemoryEvaluationRepository.java  org/anima/alma/evaluation/ResultPageRequest.java org/anima/alma/evaluation/TableSchema.java org/anima/alma/evaluation/DefaultAnalysisExecutor.java org/anima/alma/evaluation/EvaluationRepository.java org/anima/alma/evaluation/EvaluationStatus.java org/anima/alma/evaluation/PluckTableName.java org/anima/alma/evaluation/SoutAsResultsWriter.java   ...

do it MANUALLY



And non-java files? Resources? Images? Libraries?


There is no clear definition of what the project is, or what is it made of.

we need a descriptor





A way to describe the project and its build process.

DO We need a descriptor ?





Hey, wait.
My IDE does that, what's the point?

eclipse's .project

 

Bluej's package.bluej

 

DrJava's drjava-proj.drjava

we need a descriptor



They're all incompatible!

The IDE is a personal and arbitrary choice, the way we build the software should not be dependent on it.




(Yes, you can "import" projects between IDEs, but it's tedious and it doesn't always do what we expect)

we need a descriptor





A way to describe completely the build process, and to be able to run it in any environment without need for further configuration.

code generation tools



JavaCC

 allows you to define a language grammar and creates a .java parser for it.

code generation tools





Cool, I'll try it out!


code generation tools

Here's my Dna.jj!
 

code generation tools

Generate the parser...

code generation tools

RUN!

But it's not exactly what I wanted.
(yeah, my DNA has 'Z' too.)

code generation tools

take Dna.jj, add 'Z' as a valid token, RUN and...

Same result as before.

code generation tools


WTF?



Parser must be regenerated manually!

we need automation





The descriptor must be machine-executable and must be able to perform arbitrary tasks, even involving external tools.

dependency management

Import bundled Spring framework 3.0.2

dependency management

After 2 months...

dependency management

I'll just bump 'spring-expression' to 3.2.0...
 

dependency management

manually.

dependency management

Oh, it depends form the same version of 'core'...

dependency management

SHI**.. now everything must be at the same version as 'core'!

dependency management



Search,
download,
add,
rinse,
repeat...

Manually.

we need support





There are some tasks that requires human intervention. We need support and automation on that.

murphy's law




When things goes terribly wrong, you definitely want access to a detailed textual log output or the debug mode.



(Cases so rare that I couldn't reproduce one in two weeks)

murphy's law


we need transparency





Sometimes when features are provided through an higher-level broker details are hidden or hard to see.



descriptor

automation

support

transparency

}=>



QUALITY



less defective, reliable software





(with no additional developing costs!)


and that means




waste reduction





(and less waste == more €€€)




what could i find out there?



what could i find out there?






2 main currents:

what could i find out there?


THE LIBRARY WAY


 Provides a set of "building blocks" to detail how a task is accomplished


Which tasks are to run and their dependencies is expressed declaratively

what could i find out there?


THE LIBRARY WAY


flexible (full customization is possible)

complicated (it's another language)
-drift: no two projects have similar builds


what could i find out there?


"When a coworker informs me that he’s switching the build process to yet another Turing-complete JVM-based build tool"
 
(from This PLT Life)

what could i find out there?


THE LIBRARY WAY

 +

what could i find out there?


THE FRAMEWORK WAY


Provides a mean to declare your intentions of what should be done as preconfigured "goals"


And the possibility to define your own in a "plug-in" fashion

what could i find out there?


THE FRAMEWORK WAY

 + conv-over-conf: "as long as you follow conventions, you're free from configuration"  

 hard to customize: adapting for a customized task might be painful

+hard to customize:  refrain from reinventing the wheel or breaking conventions without a good reason


what could i find out there?


THE FRAMEWORK WAY




what could i find out there?


THE MIDDLE WAY



Declarative, but with the possibility to shift to imperative when really needed

(and with a full-featured language)

what could i find out there?


THE MIDDLE WAY






thanks





Made with Slides.com