<<

Ant, Maven,

Evoluzione della specie Build tool. Ant - https://ant.apache.org/

Apache Ant is a library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. Ant - il coltellino svizzero

L’equivalente di un “” scritto in Java. ● Comandi standard predefinitie dipendenti. ● Comandi e dipendenze aggiungibili. Ant looks like….

simple example build file

...

https://ant.apache.org/manual/index.html Ant looks like….

...

...

https://ant.apache.org/manual/index.html Ant looks like….

...

https://ant.apache.org/manual/index.html .... Problemi irrisolti da Ant

● Spaghetti JAR in /lib e classpath. ● Assenza di regole per un Buon progetto. ● Solo Comandi. Organizzazione minimalista. Maven - Wikipedia

A maven (also mavin) is a trusted expert in a particular field, who seeks to pass knowledge on to others. The word maven comes from Hebrew, meaning "one who understands", based on an accumulation of knowledge. Maven for Ant Users http://maven.apache.org/archives/maven-1.x/using/migrating.html#Maven_for_Ant_Users

You may have heard that Maven(1) is just Ant plus dependencies, or a set of reusable Ant scripted plugins. But in fact, the aims of the two products are quite different. Maven - https://maven.apache.org/

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Maven - esperienza codificata

I punti fondanti la nascita del progetto: ● convenzioni ● dipendenze transitive tra librerie JAR ● repository ● espandibilità ordinata Maven files

● settings. (multiprogetto globali e personali) ● pom.xml (per progetto) Maven settings looks like...

...

https://maven.apache.org/settings.html Maven settings looks like...

https://maven.apache.org/settings.html Maven pom looks like ...

4.0.0

com.mycompany.app my-app 1.0 ... https://en.wikipedia.org/wiki/Apache_Maven#History Maven pom looks like ...

junit junit 3.8.1 https://en.wikipedia.org/wiki/Apache_Maven#History Maven pom looks like ...

test

https://en.wikipedia.org/wiki/Apache_Maven#History Maven dir layout

https://en.wikipedia.org/wiki/Apache_Maven#History Maven1 ?

L’impianto di Maven 1 era troppo debole per supportare la visione del progetto. La versione 2 fu corretta e divenne standard di fatto per le build Java. Maven2

Maven 2.0 is based around the central concept of a build lifecycle. What this means is that the process for building and distributing a particular artifact (project) is clearly defined.

Ora Ant è un di cui e non più centrale. Maven2 lifecycle

1. validate - validate the project is correct and all necessary information is available 2. compile - compile the source code of the project 3. test - test the compiled source code using a suitable framework. These tests should not require the code be packaged or deployed 4. package - take the compiled code and package it in its distributable format, such as a JAR. 5. integration-test - process and deploy the package if necessary into an environment where integration tests can be run 6. verify - run any checks to verify the package is valid and meets quality criteria 7. install - install the package into the local repository, for use as a dependency in other projects locally 8. deploy - done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. These build phases (plus the other build phases not shown here) are executed sequentially to complete the default lifecycle. https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html Maven 3

Maven 1.x and Maven 2.x have now reached their end of (development) life. but...2.x è stato impiegato in molte build di sistemi complessi oggi in produzione. Maven 3

Maven 3 aims to ensure backward compatibility with Maven 2, improve usability, increase performance, allow safe embedding, and pave the way to implement many highly demanded features. Maven - history

Maven, created by Takari's Jason van Zyl, began as a subproject of Apache Turbine in 2002. In 2003, it was voted on and accepted as a top level Apache Software Foundation project. In July 2004, Maven's release was the critical first milestone, v1.0. Maven 2 was declared v2.0 in October 2005 after about six months in beta cycles. Maven 3.0 was released in October 2010 being mostly backwards compatible with Maven 2.

Maven 3.0 has reworked the core Project Builder infrastructure...This has expanded the possibility for Maven 3.0 add-ons to leverage non-XML based project definition files. Languages suggested include Ruby (already in private prototype by Jason van Zyl), YAML, and Groovy.

Special attention was given to ensuring backward compatibility of Maven 3 to Maven 2. Maven attuali alternative

Ivy: il complemento di Ant, se meno è più.

Maven AntTasks: The Maven Ant Tasks allow many of the features of Maven, such as dependency management and repository deployment, to be used in an Ant build. Leniant: la build secondo Closure Sbt: la build secondo Scala Gradle: la build secondo Groovy Ivy - http://ant.apache.org/ivy/

Apache Ivy™ is a popular dependency manager focusing on flexibility and simplicity. Ivy - la transitività

Complemento di Ant per i problemi di: ● dipendenze transitive tra JAR ● repository, diversi da maven ○ maven2 repo support Gradle - linguaggio di build

Una DSL per build, codificata in Groovy. Groovy

Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform, is dynamically compiled to (JVM) bytecode, and interoperates with other Java code and libraries. Groovy uses a Java-like curly- bracket syntax. Most Java code is also syntactically valid Groovy, although semantics may be different. Gradle DSL

Gradle is a project automation tool that builds upon the concepts of and and introduces a Groovy-based domain-specific language (DSL) instead of the more traditional XML form of declaring the project configuration. Gradle from main site

Polyglot Builds JVM languages Android plugin Native binary plugins: /C++ ‧ Objective-C/C++ ‧ Assembly ‧ CUnit Robust Dependency Management Maven, Ivy, Flat, Ant Powerful Yet Concise Logic ... Gradle from main site

... High Performance Builds Caches build steps Partial builds Build deamon Parallel test Tool Integrations Build Reporting Gradle DAG

Unlike Apache Maven, which defines lifecycles, and Apache Ant, where targets are invoked based upon a depends-on partial ordering, Gradle uses a directed acyclic graph ("DAG") to determine the order in which tasks can be run. Gradle multiproject

Gradle was designed for multi-project builds which can grow to be quite large, and supports incremental builds by intelligently determining which parts of the build tree are up- to-date, so that any task dependent upon those parts will not need to be re-executed. Gradle multilanguage

The initial plugins are primarily focused around Java, Groovy and Scala development and deployment, but more languages and project workflows are on the roadmap. Gradle Looks like.. apply plugin: 'java' group = 'org.gradle.example' version = '1.0.0' sourceCompatibility = targetCompatibility = 1.7 repositories { mavenCentral() }

... https://www.gradle.org/why/powerful-yet-concise-logic/#tab-id-1 Gradle Looks like..

… dependencies { compile 'org.slf4j:slf4j-api:1.7.10' runtime 'org.slf4j:slf4j-simple:1.7.10' testCompile 'junit:junit:4.12' }

...

https://www.gradle.org/why/powerful-yet-concise-logic/#tab-id-1 Gradle Looks like..

{ manifest { attributes 'Main-Class': "${project.group}.App" } } task sourceJar(type: Jar) { classifier = 'sources' from sourceSets.main.allSource } https://www.gradle.org/why/powerful-yet-concise-logic/#tab-id-1 Grazie