Your SlideShare is downloading. ×
0
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Maven

2,543

Published on

Introduzione a Maven @ JUG Genova 20/05/2008

Introduzione a Maven @ JUG Genova 20/05/2008

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,543
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
34
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Maven <ul><ul><li>“ Tutto” quello che NON avreste </li></ul></ul><ul><ul><li>MAI voluto sapere... </li></ul></ul><ul><ul><li>( http://maven.apache.org/ ) </li></ul></ul><ul><ul><li>JUG-Genova </li></ul></ul><ul><ul><li>Fabio Bonfante </li></ul></ul><ul><ul><li>Carlo Bonamico </li></ul></ul>
  • 2. L'origine... Maven 1.x <ul><li>Condizioni dello sviluppatore dopo un uso intensivo di Maven 1 su progetti di grandi dimensioni (Fortunatamente con Maven 2 è tutta un'altra cosa...) </li></ul>
  • 3. L'evoluzione... Maven 2 <ul><li>Condizioni dello sviluppatore dopo un uso intensivo di maven 2 (La situazione è nettamente migliorata!) </li></ul>
  • 4. Cos'è Maven <ul><li>Maven is essentially a project management and comprehension tool and as such provides a way to help with managing: </li></ul><ul><ul><li>Builds </li></ul></ul><ul><ul><li>Documentation </li></ul></ul><ul><ul><li>Reporting </li></ul></ul><ul><ul><li>Dependencies </li></ul></ul><ul><ul><li>SCMs </li></ul></ul><ul><ul><li>Releases, Distribution </li></ul></ul>
  • 5. Installazione e configurazione <ul><li>Unzip </li></ul><ul><li>M2_HOME – path/to/installed-maven </li></ul><ul><li>MAVEN_OPTS – opzioni JVM </li></ul><ul><li><user>/.m2/settings.xml </li></ul><ul><li><user>/.m2/repository – posizione di default del repository locale </li></ul>
  • 6. Concetti base: Ciclo di Build <ul><li>Build Lifecycle Phases (principali) </li></ul><ul><ul><li>validate - validate the project is correct and all necessary information is available </li></ul></ul><ul><ul><li>compile - compile the source code of the project </li></ul></ul><ul><ul><li>test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed </li></ul></ul><ul><ul><li>package - take the compiled code and package it in its distributable format, such as a JAR. </li></ul></ul>
  • 7. Concetti base: Ciclo di Build <ul><ul><li>integration-test - process and deploy the package if necessary into an environment where integration tests can be run </li></ul></ul><ul><ul><li>verify - run any checks to verify the package is valid and meets quality criteria </li></ul></ul><ul><ul><li>install - install the package into the local repository, for use as a dependency in other projects locally </li></ul></ul><ul><ul><li>deploy - done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. </li></ul></ul>
  • 8. Concetti base: POM <ul><li>Fasi “extra” del ciclo di build </li></ul><ul><ul><li>clean : cleans up artifacts created by prior builds </li></ul></ul><ul><ul><li>site : generates site documentation for this project </li></ul></ul><ul><li>Project Object Model (POM, pom.xml) </li></ul><ul><ul><li>Definisce il progetto, le sue dipendenze e come deve essere compilato. </li></ul></ul>
  • 9. Concetti Base: Standard Directory Layout <ul><li>src/main/java Application/Library sources </li></ul><ul><li>src/main/resources Application/Library resources </li></ul><ul><li>src/main/filters Resource filter files </li></ul><ul><li>src/main/assembly Assembly descriptors </li></ul><ul><li>src/main/config Configuration files </li></ul><ul><li>src/main/webapp Web application sources </li></ul><ul><li>src/test/java Test sources </li></ul><ul><li>src/test/resources Test resources </li></ul><ul><li>src/test/filters Test resource filter files </li></ul><ul><li>src/site Site </li></ul>
  • 10. Build with Maven... (shell) <ul><li>Creare un progetto </li></ul><ul><li>mvn archetype:create -DgroupId=ge.jug.samples -DartifactId=zeroapp </li></ul><ul><li>Compilarlo: mvn package </li></ul><ul><li>Eseguirlo </li></ul><ul><li>java -cp target/zeroapp-1.0-SNAPSHOT.jar ge.jug.samples.App </li></ul>
  • 11. Build with Maven <ul><li>Uno sguardo al POM... </li></ul><ul><li>Ogni cosa è una plug-in... <build> </li></ul><ul><li><plugins> </li></ul><ul><li>< plugin > </li></ul><ul><li><groupId>org.apache.maven.plugins</groupId> </li></ul><ul><li><artifactId>maven-compiler-plugin</artifactId> </li></ul><ul><li><version>2.0.2</version> </li></ul><ul><li>< configuration > </li></ul><ul><li><source>1.5</source> </li></ul><ul><li><target>1.5</target> </li></ul><ul><li></ configuration > </li></ul><ul><li></ plugin > </li></ul><ul><li></plugins> </li></ul><ul><li></build> </li></ul>
  • 12. Build with Maven <ul><li>Build di più progetti </li></ul><ul><li>+- pom.xml </li></ul><ul><li>+- my-app </li></ul><ul><li>| +- pom.xml </li></ul><ul><li>| +- src </li></ul><ul><li>| +- main </li></ul><ul><li>| +- java </li></ul><ul><li>+- my-webapp </li></ul><ul><li>| +- pom.xml </li></ul><ul><li>| +- src </li></ul><ul><li>| +- main </li></ul><ul><li>| +- webapp </li></ul>
  • 13. Build with Maven <ul><li>Struttura del POM radice </li></ul><ul><li><project ....> </li></ul><ul><li><modelVersion>4.0.0</modelVersion> </li></ul><ul><li><groupId>com.mycompany.app</groupId> </li></ul><ul><li><version>1.0-SNAPSHOT</version> </li></ul><ul><li><artifactId>app</artifactId> </li></ul><ul><li><packaging> pom </packaging> </li></ul><ul><li><modules> </li></ul><ul><li><module>my-app</module> </li></ul><ul><li><module>my-webapp</module> </li></ul><ul><li></modules> </li></ul><ul><li></project> </li></ul>
  • 14. Build with Maven... testing <ul><li>By default the tests included are: </li></ul><ul><ul><li>**/*Test.java </li></ul></ul><ul><ul><li>**/Test*.java </li></ul></ul><ul><ul><li>**/*TestCase.java </li></ul></ul><ul><li>And the default excludes are: </li></ul><ul><ul><li>**/Abstract*Test.java </li></ul></ul><ul><ul><li>**/Abstract*TestCase.java </li></ul></ul>
  • 15. Build with Maven <ul><li><groupId>org.apache.maven.plugins</groupId> </li></ul><ul><li><artifactId>maven-surefire-plugin</artifactId> </li></ul><ul><li><version>2.4-SNAPSHOT</version> </li></ul><ul><li><configuration> </li></ul><ul><ul><li><includes> </li></ul></ul><ul><ul><li><include>**/*QueryService.java </li></ul></ul><ul><ul><li></include> </li></ul></ul><ul><ul><li></includes> </li></ul></ul><ul><ul><li><excludes> </li></ul></ul><ul><ul><li><exclude>**/FillDBTest.java</exclude> </li></ul></ul><ul><ul><li></excludes> </li></ul></ul><ul><li></configuration> </li></ul>
  • 16. Build with Maven <ul><li>Aggiunta di file di risorse </li></ul><ul><li><build> </li></ul><ul><li><resources> </li></ul><ul><li><resource> <directory>src/main/resources</directory> </li></ul><ul><li><filtering>true</filtering> </li></ul><ul><li></resource> </li></ul><ul><li></resources> </li></ul><ul><li></build> </li></ul>
  • 17. Integrazione con Eclipse <ul><li>Generazione file di progetto per Eclipse </li></ul><ul><ul><li>mvn eclipse:eclipse </li></ul></ul><ul><li>Plugin disponibili </li></ul><ul><ul><li>Maven Integration for Eclipse </li></ul></ul><ul><ul><li>http://m2eclipse.sonatype.org/update/ </li></ul></ul><ul><ul><li>Q for Eclipse </li></ul></ul><ul><ul><li>http://q4e.googlecode.com/svn/trunk/updatesite/ </li></ul></ul>
  • 18. Integrazione con Netbeans <ul><li>Tools > Plugins </li></ul>
  • 19. Riferimenti <ul><li>Maven home page </li></ul><ul><ul><li>http://maven.apache.org/ </li></ul></ul><ul><li>Maven: The Definitive Guide </li></ul><ul><ul><li>http://www.sonatype.com/book/ </li></ul></ul><ul><li>Better build with Maven </li></ul><ul><ul><li>http://www.mergere.com/m2book_download.jsp </li></ul></ul>

×