170 likes | 179 Views
Maven 04 March 2016. Introduction. Java projects originally managed with Ant Manual build process Ant scripts to compile, generate IDL, jar Low-level scripting No dependency management No version management. Introduction. Java projects originally managed with Ant
E N D
Maven 04 March 2016
Introduction • Java projects originally managed with Ant • Manual build process • Ant scripts to compile, generate IDL, jar • Low-level scripting • No dependency management • No version management
Introduction • Java projects originally managed with Ant • Manual build process • Ant scripts to compile, generate IDL, jar • Low-level scripting • No dependency management • No version management • Maven provides high-level features for build process
Maven vs Ant • Ant originated from the Apache Tomcat project in early 2000 • Individual build.xml • No constraints on the build process • Maven initial release in july 2004 • Shared pom.xml • Published on shared repositories • Build process constrained
Maven build lifecycle • Artifact concept • Java “package” to be deployed • Different types of artifact (jar, war, plugin, …) • Dependent lifecycle • Phases for jar • process-resources, compile, process-test-resources, test-compile, test, package, install, deploy • Default behaviour
Maven dependencies • All the dependencies are defined • Example : <dependency> <groupId>avalon-framework</groupId> <artifactId>avalon-framework-impl</artifactId> <version>4.2.0</version> </dependency> • Maven automatically updates and downloads the jar
Maven repositories • Important concept of Maven • Every artifact is published to a repository • 4 types of repository • Central • Public • Private • Local
Maven repositories • Nexus Repository • ILL private • https://maven.ill.fr/ • Releases • Snapshots • Central mirror or proxy • Thirdparty • Compilation on the instruments • Nexus users, right to publish snapshots, releases
Maven plugins • A type of dependency • Customize the build • Examples • Force compilation in Java 1.7 rather than default • Incorporate SVN revision in jar • Generate a single jar that contains all the dependencies • Android support • Share the code
Code versioning • Every artifact has a version • Nomad and NomadCommandSystem must be versioned • Nomad and NomadCommandSystem can have dissociated versions • Nomad can reference an older NomadCommandSystem • Version strategy to be defined
Code versioning strategy • Release vs Snapshot • Deploy a release only once • Deploy multiple snapshots during development • Version deployment example • 1.2.1 deployed • 1.2.2-SNAPSHOT deployed • 1.2.2-SNAPSHOT deployed • … • 1.2.2 deployed • Changelog to be updated (ideally for each commit)
Code versioning strategy • Version numbering • Not important for an application (e.g. NomadGUI) • Important for a library (e.g. NomadCommmandSystem) • We can discuss it major.minor.revision
Profiles • Possibility to define profiles • Build for different platforms • SWT profiles for GTK 32bits, GTK 64bits • Default profile in .m2/settings.xml
Modules • Maven own module concept • A module inherits parent pom.xml • Deployment can be independent • Project NomadGUISpecialModules
Day to day usage • Maven not required to run NomadGUI • Maven required to compile NomadGUI, NomadCommandSystem, Cameo server and API • Eclipse integration • Command-line > mvn install > mvn -P gtk_linux_x86 install
Conclusion • Maven has lots of features • But with a well-defined organization, will bring more than it costs