SlideShare a Scribd company logo
1 of 49
Download to read offline
Maven & Cª
                         Gestão de Builds e Dependências




 Ruben Badaró
 4º Encontro PT.JUG - 29 Jan 09
Sunday 1 February 2009
Gestão de Builds

                   • Processo moroso e repetitivo
                   • Não se resume a construir software: testar
                         artefactos, análise estática, etc.
                   • Processo homogéneo para toda a equipa


Sunday 1 February 2009
Variedade



                         Raven




Sunday 1 February 2009
Desafios

                   • Automatizar builds
                   • Onde guardar bibliotecas
                   • Manter dependências de bibliotecas


Sunday 1 February 2009
Sunday 1 February 2009
Gestão de Dependências

                   •     Múltiplos Componentes

                   •     Componentes
                                                     B
                                                 A
                         dependem de outros
                         componentes

                   •     Múltiplas versões




Sunday 1 February 2009
Dependências Transitivas


                                          C
                             A


                                    B



Sunday 1 February 2009
JAR Hell




Sunday 1 February 2009
JAR Hell

                                B
                         A     0.1




                         C      B
                               0.2




Sunday 1 February 2009
Maven



Sunday 1 February 2009
Maven significa “aquele que acumula
                               conhecimento” em iídiche.
                         Um especialista numa determinada área
                         que procura passar o seu conhecimento.

Sunday 1 February 2009
Definição

                  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.




Sunday 1 February 2009
Objectivos

                   • Convention Over Configuration
                   • One size does not fit all
                   • Partilhar JARs entre projectos
                   • Informação sobre projecto facilmente
                         acessível



Sunday 1 February 2009
Características
                   •                              •
                         Builds automatizados         Plugins são cidadãos de
                                                      1ª classe
                   •     Lifecycle bem definido
                                                  •   Quickstart rápido de
                   •                                  projectos
                         Repositório de
                         artefactos
                                                  •   Site de projecto
                   •                                  facilmente acessível
                         Gestão de Dependências

                                                  •
                   •                                  Integração com VCS
                         Definição de Projectos
                         declarativa (POM)




Sunday 1 February 2009
Ant vs. Maven
                                 Ant                  Maven

                                                 Convention Over
                         Não tem convenções
                                                  Configuration

                            Procedimental          Declarativo

                         Sem Lifecycle definido   Lifecycle definido



Sunday 1 February 2009
Hierarquia Definida




Sunday 1 February 2009
POM

                   • Project Object Model
                   • Herança e agregação de projectos
                   • Definições de projecto
                   • Customizações (definições para plugins,
                         repositórios, etc.)



Sunday 1 February 2009
POM - Configuração
                              mínima




Sunday 1 February 2009
POM - propriedades

                   • groupId (nome do package - empresa)
                   • artifactId (identificador do projecto)
                   • packaging (pom, war, jar, etc. - default jar)
                   • version (versão de release ou SNAPSHOT)
                   • classifier

Sunday 1 February 2009
POM - Herança




Sunday 1 February 2009
POM - Herança




Sunday 1 February 2009
POM - Agregação




Sunday 1 February 2009
Plugins

                   • Cidadãos de 1ª classe
                   • Core do Maven simples - funcionalidades
                         implementadas em plugins
                   • Ecossistema de 3rd parties rico
                   • Acessível criar os próprios plugins

Sunday 1 February 2009
Plugins
                   • Cada plugin tem goals - Mojos
                   • Plugin associado a fase do lifecycle
                   • Invocação de um plugin/goal

                   • Invocação de uma fase

Sunday 1 February 2009
Custom Plugins

                   • Usar archetype para criar



                   • Cria pom com packaging maven-plugin

Sunday 1 February 2009
Custom Plugins - Convenções


                   • prefix-maven-plugin / maven-prefix-plugin
                   • Implementar Mojo com nome GoalMojo
                   • @goal goalName

                   • Adicionar groupId ao settings.xml

Sunday 1 February 2009
Custom Plugins

                   • Também possível em Ant
                   • ${basedir}/src/main/scripts/goal.build.xml
                   • ${basedir}/src/main/scripts/goal.mojo.xml
                   • E noutras linguagens que se queira: Ruby,
                         Groovy



Sunday 1 February 2009
Lifecycles
                   • Sequência de fases com goals associados
                   • 3 tipos
                     • Build lifecycle
                     • Clean lifecycle
                     • Site lifecycle
                   • Possível definir custom lifecycle ou fazer
                         override


Sunday 1 February 2009
Build Lifecycle
                         validate           generate-test-sources          package



                    generate-sources        process-test-sources     pre-integration-test



                     process-sources       generate-test-resources     integration-test



                   generate-resources      process-test-resources    post-integration-test



                   process-resources            test-compile                verify



                         compile                    test                    install



                     process-classes          prepare-package               deploy


Sunday 1 February 2009
Build Lifecycle - JAR
                         validate        generate-test-sources          package



                    generate-sources     process-test-sources     pre-integration-test



                     process-sources    generate-test-resources     integration-test



                   generate-resources   process-test-resources    post-integration-test



                   process-resources         test-compile                verify



                         compile                 test                    install



                     process-classes       prepare-package               deploy


Sunday 1 February 2009
Build Lifecycle - JAR
                              process-resources            test

                             resources:resources      surefire:test


                                   compile              package

                               compiler:compile          jar:jar


                            generate-test-resources      install

                            resources:testResources   install:install


                                 test-compile            deploy

                             compiler:testCompile     deploy:deploy



Sunday 1 February 2009
Profiles
                   • Permite criar perfis de ambientes de build
                   • Faz-se override a configurações (quase
                         todas)
                   • Invoca-se com -P na linha de comandos
                   • Alternativamente, usam-se activations (jdk,
                         os, props)


Sunday 1 February 2009
Repositório

                   • Todos os artefactos e plugins guardados
                         num repositório local
                   • Dependências externas são carregadas para
                         repo local
                   • Pode-se sempre instalar directamente no
                         repo local



Sunday 1 February 2009
Repositório

                   • Localizado em $user_home/.m2
                   • Segue estrutura bem definida
                   • Criar repositórios proxy a nível da
                         organização
                   • Apontar alterando settings.xml ou no POM

Sunday 1 February 2009
Repositório
               Internet      Rede Empresarial   Local



                   Repo            Repo         Repo
                  Central          Proxy        Local




Sunday 1 February 2009
Repositório
               •         Repositório central:
                         http://repo1.maven.org/maven2
               •         Pesquisa online:
                         http://mvnrepository.com
               •         Ferramentas úteis
                         •   Archiva
                         •   Nexus


Sunday 1 February 2009
SNAPSHOTS

                   • Se versão incluir “SNAPSHOT” é
                         considerada em desenvolvimento
                   • Maven executa lifecycle sempre se for
                         SNAPSHOT




Sunday 1 February 2009
Gestão de dependências

                   • Suporta dependências transitivas
                   • Resolve dependências de dependências

                   • scope: compile (default), provided, runtime,
                         test, system



Sunday 1 February 2009
Gestão de dependências

                   • Range versions: [ ] e ( )
                   • Dependências opcionais (optional)
                   • Excluir dependências
                    - Para resolver conflitos
                    - Para substituir dependências transitivas

Sunday 1 February 2009
Archetypes
                   • Templates de projectos
                   • Appfuse é um bom exemplo




Sunday 1 February 2009
Archetypes
                   • Mais simples ainda

                   • Entra em modo interactivo e lista todos os
                         archetypes disponíveis
                   • Ex: maven-archetype-quickstart, maven-
                         archetype-webapp, maven-archetype-mojo


Sunday 1 February 2009
Integração Ant
                   •     3 aproximações típicas:
                         •   Usar tasks Ant no Maven: maven-antrun-
                             plugin
                             -   Não copiar script Ant para o POM. Deixar
                                 num build.xml e usar <ant>
                         •   Ant tasks for Maven: conjunto de tasks que
                             disponibilizam funcionalidades Maven
                         •   Plugins em scripts Ant


Sunday 1 February 2009
Integração Ant




Sunday 1 February 2009
Site
                   • Geração automática de site de projecto
                   • Info de projecto e equipa
                   • Relatórios
                   • Personalizável
                   • Deployable (scp, ftp, dav)
                   • Custom templating - usa Doxia que usa
                         Velocity

Sunday 1 February 2009
Best Practices
                   • Planear
                   • Usar plugins dos IDEs
                   • Archetypes para quickstart - criar os
                         vossos próprios para projectos internos
                   • Deixar parametrizações personalizadas no
                         settings.xml
                   • Evolução progressiva em migrações de Ant
Sunday 1 February 2009
Best Practices
                   • Utilizar profiles para ambientes - DEV,
                         QUA, PROD, ...
                   • Dependendo do profile, usar SNAPSHOTS
                         para DEV e integrar releases com controlo
                         de versões - maven-release-plugin
                   • Enquadrar “módulos” de controlos de
                         versões com dependências


Sunday 1 February 2009
Best Practices
                   • Não repetir dependências desnecessárias
                   • Parametrizar plugins existentes antes de
                         criar novos
                   • Usar proxy repositories
                   • Usar integração contínua (Continuum,
                         Hudson, Atlassian Bamboo, JetBrains
                         Teamcity)


Sunday 1 February 2009
Pequeno twist - Buildr
                   • Maven para quem é cool
                   • Escreve-se em Ruby no lugar de XML
                   • Usa mesmo layout e repositórios que
                         maven
                   • Mas não é directo passar de POM para
                         buildfile
                   • Menos declarativo, mais poderoso
Sunday 1 February 2009
The End

                         Perguntas? Jantar?


                                   Ruben Badaró
                              ruben.badaro@gmail.com
                                http://www.zonaj.org




Sunday 1 February 2009

More Related Content

Similar to Maven - Gestão de Builds e Dependencias

IT Depends: Custom vs Packaged Software
IT Depends: Custom vs Packaged SoftwareIT Depends: Custom vs Packaged Software
IT Depends: Custom vs Packaged Software★ Selcuk Atli
 
Talk About Configuration Management
Talk About Configuration ManagementTalk About Configuration Management
Talk About Configuration ManagementGuixing Bai
 
Practical Groovy Domain-Specific Languages - Guillaume Laforge - Usi 2009
Practical Groovy Domain-Specific Languages - Guillaume Laforge - Usi 2009Practical Groovy Domain-Specific Languages - Guillaume Laforge - Usi 2009
Practical Groovy Domain-Specific Languages - Guillaume Laforge - Usi 2009Guillaume Laforge
 
Web Standards and Accessibility
Web Standards and AccessibilityWeb Standards and Accessibility
Web Standards and AccessibilityNick DeNardis
 
Software Engineering In PHP
Software Engineering In PHPSoftware Engineering In PHP
Software Engineering In PHPRalph Schindler
 
No Really, It's All About You
No Really, It's All About YouNo Really, It's All About You
No Really, It's All About YouChris Cornutt
 
CouchDB to the Edge ApacheCon EU
CouchDB to the  Edge ApacheCon EUCouchDB to the  Edge ApacheCon EU
CouchDB to the Edge ApacheCon EUChris Anderson
 
Maven 2 in the real world
Maven 2 in the real worldMaven 2 in the real world
Maven 2 in the real worldCarlo Bonamico
 
Portlets
PortletsPortlets
Portletsssetem
 
Alpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenAlpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenArnaud Héritier
 
Building Scale Free Applications with Hadoop and Cascading
Building Scale Free Applications with Hadoop and CascadingBuilding Scale Free Applications with Hadoop and Cascading
Building Scale Free Applications with Hadoop and Cascadingcwensel
 
What is Ruby on Rails?
What is Ruby on Rails?What is Ruby on Rails?
What is Ruby on Rails?Karmen Blake
 
Lausanne Jug (08th April, 2010) - Maven
Lausanne Jug (08th April, 2010) - MavenLausanne Jug (08th April, 2010) - Maven
Lausanne Jug (08th April, 2010) - MavenArnaud Héritier
 
Apache Maven at GenevaJUG by Arnaud Héritier
Apache Maven at GenevaJUG by Arnaud HéritierApache Maven at GenevaJUG by Arnaud Héritier
Apache Maven at GenevaJUG by Arnaud HéritierGenevaJUG
 
Geneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - MavenGeneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - MavenArnaud Héritier
 
Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]Ajax Experience 2009
 
Riviera JUG (20th April, 2010) - Maven
Riviera JUG (20th April, 2010) - MavenRiviera JUG (20th April, 2010) - Maven
Riviera JUG (20th April, 2010) - MavenArnaud Héritier
 
How to Bring Your Blog to Life
How to Bring Your Blog to LifeHow to Bring Your Blog to Life
How to Bring Your Blog to LifeBruce Sharpe
 

Similar to Maven - Gestão de Builds e Dependencias (20)

IT Depends: Custom vs Packaged Software
IT Depends: Custom vs Packaged SoftwareIT Depends: Custom vs Packaged Software
IT Depends: Custom vs Packaged Software
 
Talk About Configuration Management
Talk About Configuration ManagementTalk About Configuration Management
Talk About Configuration Management
 
Practical Groovy Domain-Specific Languages - Guillaume Laforge - Usi 2009
Practical Groovy Domain-Specific Languages - Guillaume Laforge - Usi 2009Practical Groovy Domain-Specific Languages - Guillaume Laforge - Usi 2009
Practical Groovy Domain-Specific Languages - Guillaume Laforge - Usi 2009
 
Web Standards and Accessibility
Web Standards and AccessibilityWeb Standards and Accessibility
Web Standards and Accessibility
 
Software Engineering In PHP
Software Engineering In PHPSoftware Engineering In PHP
Software Engineering In PHP
 
No Really, It's All About You
No Really, It's All About YouNo Really, It's All About You
No Really, It's All About You
 
CouchDB to the Edge ApacheCon EU
CouchDB to the  Edge ApacheCon EUCouchDB to the  Edge ApacheCon EU
CouchDB to the Edge ApacheCon EU
 
Maven 2 in the real world
Maven 2 in the real worldMaven 2 in the real world
Maven 2 in the real world
 
Portlets
PortletsPortlets
Portlets
 
Struts 2.x
Struts 2.xStruts 2.x
Struts 2.x
 
Alpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenAlpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache Maven
 
Building Scale Free Applications with Hadoop and Cascading
Building Scale Free Applications with Hadoop and CascadingBuilding Scale Free Applications with Hadoop and Cascading
Building Scale Free Applications with Hadoop and Cascading
 
fingertips
fingertipsfingertips
fingertips
 
What is Ruby on Rails?
What is Ruby on Rails?What is Ruby on Rails?
What is Ruby on Rails?
 
Lausanne Jug (08th April, 2010) - Maven
Lausanne Jug (08th April, 2010) - MavenLausanne Jug (08th April, 2010) - Maven
Lausanne Jug (08th April, 2010) - Maven
 
Apache Maven at GenevaJUG by Arnaud Héritier
Apache Maven at GenevaJUG by Arnaud HéritierApache Maven at GenevaJUG by Arnaud Héritier
Apache Maven at GenevaJUG by Arnaud Héritier
 
Geneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - MavenGeneva Jug (30th March, 2010) - Maven
Geneva Jug (30th March, 2010) - Maven
 
Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]
 
Riviera JUG (20th April, 2010) - Maven
Riviera JUG (20th April, 2010) - MavenRiviera JUG (20th April, 2010) - Maven
Riviera JUG (20th April, 2010) - Maven
 
How to Bring Your Blog to Life
How to Bring Your Blog to LifeHow to Bring Your Blog to Life
How to Bring Your Blog to Life
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Maven - Gestão de Builds e Dependencias

  • 1. Maven & Cª Gestão de Builds e Dependências Ruben Badaró 4º Encontro PT.JUG - 29 Jan 09 Sunday 1 February 2009
  • 2. Gestão de Builds • Processo moroso e repetitivo • Não se resume a construir software: testar artefactos, análise estática, etc. • Processo homogéneo para toda a equipa Sunday 1 February 2009
  • 3. Variedade Raven Sunday 1 February 2009
  • 4. Desafios • Automatizar builds • Onde guardar bibliotecas • Manter dependências de bibliotecas Sunday 1 February 2009
  • 6. Gestão de Dependências • Múltiplos Componentes • Componentes B A dependem de outros componentes • Múltiplas versões Sunday 1 February 2009
  • 7. Dependências Transitivas C A B Sunday 1 February 2009
  • 8. JAR Hell Sunday 1 February 2009
  • 9. JAR Hell B A 0.1 C B 0.2 Sunday 1 February 2009
  • 11. Maven significa “aquele que acumula conhecimento” em iídiche. Um especialista numa determinada área que procura passar o seu conhecimento. Sunday 1 February 2009
  • 12. Definição 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. Sunday 1 February 2009
  • 13. Objectivos • Convention Over Configuration • One size does not fit all • Partilhar JARs entre projectos • Informação sobre projecto facilmente acessível Sunday 1 February 2009
  • 14. Características • • Builds automatizados Plugins são cidadãos de 1ª classe • Lifecycle bem definido • Quickstart rápido de • projectos Repositório de artefactos • Site de projecto • facilmente acessível Gestão de Dependências • • Integração com VCS Definição de Projectos declarativa (POM) Sunday 1 February 2009
  • 15. Ant vs. Maven Ant Maven Convention Over Não tem convenções Configuration Procedimental Declarativo Sem Lifecycle definido Lifecycle definido Sunday 1 February 2009
  • 17. POM • Project Object Model • Herança e agregação de projectos • Definições de projecto • Customizações (definições para plugins, repositórios, etc.) Sunday 1 February 2009
  • 18. POM - Configuração mínima Sunday 1 February 2009
  • 19. POM - propriedades • groupId (nome do package - empresa) • artifactId (identificador do projecto) • packaging (pom, war, jar, etc. - default jar) • version (versão de release ou SNAPSHOT) • classifier Sunday 1 February 2009
  • 20. POM - Herança Sunday 1 February 2009
  • 21. POM - Herança Sunday 1 February 2009
  • 22. POM - Agregação Sunday 1 February 2009
  • 23. Plugins • Cidadãos de 1ª classe • Core do Maven simples - funcionalidades implementadas em plugins • Ecossistema de 3rd parties rico • Acessível criar os próprios plugins Sunday 1 February 2009
  • 24. Plugins • Cada plugin tem goals - Mojos • Plugin associado a fase do lifecycle • Invocação de um plugin/goal • Invocação de uma fase Sunday 1 February 2009
  • 25. Custom Plugins • Usar archetype para criar • Cria pom com packaging maven-plugin Sunday 1 February 2009
  • 26. Custom Plugins - Convenções • prefix-maven-plugin / maven-prefix-plugin • Implementar Mojo com nome GoalMojo • @goal goalName • Adicionar groupId ao settings.xml Sunday 1 February 2009
  • 27. Custom Plugins • Também possível em Ant • ${basedir}/src/main/scripts/goal.build.xml • ${basedir}/src/main/scripts/goal.mojo.xml • E noutras linguagens que se queira: Ruby, Groovy Sunday 1 February 2009
  • 28. Lifecycles • Sequência de fases com goals associados • 3 tipos • Build lifecycle • Clean lifecycle • Site lifecycle • Possível definir custom lifecycle ou fazer override Sunday 1 February 2009
  • 29. Build Lifecycle validate generate-test-sources package generate-sources process-test-sources pre-integration-test process-sources generate-test-resources integration-test generate-resources process-test-resources post-integration-test process-resources test-compile verify compile test install process-classes prepare-package deploy Sunday 1 February 2009
  • 30. Build Lifecycle - JAR validate generate-test-sources package generate-sources process-test-sources pre-integration-test process-sources generate-test-resources integration-test generate-resources process-test-resources post-integration-test process-resources test-compile verify compile test install process-classes prepare-package deploy Sunday 1 February 2009
  • 31. Build Lifecycle - JAR process-resources test resources:resources surefire:test compile package compiler:compile jar:jar generate-test-resources install resources:testResources install:install test-compile deploy compiler:testCompile deploy:deploy Sunday 1 February 2009
  • 32. Profiles • Permite criar perfis de ambientes de build • Faz-se override a configurações (quase todas) • Invoca-se com -P na linha de comandos • Alternativamente, usam-se activations (jdk, os, props) Sunday 1 February 2009
  • 33. Repositório • Todos os artefactos e plugins guardados num repositório local • Dependências externas são carregadas para repo local • Pode-se sempre instalar directamente no repo local Sunday 1 February 2009
  • 34. Repositório • Localizado em $user_home/.m2 • Segue estrutura bem definida • Criar repositórios proxy a nível da organização • Apontar alterando settings.xml ou no POM Sunday 1 February 2009
  • 35. Repositório Internet Rede Empresarial Local Repo Repo Repo Central Proxy Local Sunday 1 February 2009
  • 36. Repositório • Repositório central: http://repo1.maven.org/maven2 • Pesquisa online: http://mvnrepository.com • Ferramentas úteis • Archiva • Nexus Sunday 1 February 2009
  • 37. SNAPSHOTS • Se versão incluir “SNAPSHOT” é considerada em desenvolvimento • Maven executa lifecycle sempre se for SNAPSHOT Sunday 1 February 2009
  • 38. Gestão de dependências • Suporta dependências transitivas • Resolve dependências de dependências • scope: compile (default), provided, runtime, test, system Sunday 1 February 2009
  • 39. Gestão de dependências • Range versions: [ ] e ( ) • Dependências opcionais (optional) • Excluir dependências - Para resolver conflitos - Para substituir dependências transitivas Sunday 1 February 2009
  • 40. Archetypes • Templates de projectos • Appfuse é um bom exemplo Sunday 1 February 2009
  • 41. Archetypes • Mais simples ainda • Entra em modo interactivo e lista todos os archetypes disponíveis • Ex: maven-archetype-quickstart, maven- archetype-webapp, maven-archetype-mojo Sunday 1 February 2009
  • 42. Integração Ant • 3 aproximações típicas: • Usar tasks Ant no Maven: maven-antrun- plugin - Não copiar script Ant para o POM. Deixar num build.xml e usar <ant> • Ant tasks for Maven: conjunto de tasks que disponibilizam funcionalidades Maven • Plugins em scripts Ant Sunday 1 February 2009
  • 43. Integração Ant Sunday 1 February 2009
  • 44. Site • Geração automática de site de projecto • Info de projecto e equipa • Relatórios • Personalizável • Deployable (scp, ftp, dav) • Custom templating - usa Doxia que usa Velocity Sunday 1 February 2009
  • 45. Best Practices • Planear • Usar plugins dos IDEs • Archetypes para quickstart - criar os vossos próprios para projectos internos • Deixar parametrizações personalizadas no settings.xml • Evolução progressiva em migrações de Ant Sunday 1 February 2009
  • 46. Best Practices • Utilizar profiles para ambientes - DEV, QUA, PROD, ... • Dependendo do profile, usar SNAPSHOTS para DEV e integrar releases com controlo de versões - maven-release-plugin • Enquadrar “módulos” de controlos de versões com dependências Sunday 1 February 2009
  • 47. Best Practices • Não repetir dependências desnecessárias • Parametrizar plugins existentes antes de criar novos • Usar proxy repositories • Usar integração contínua (Continuum, Hudson, Atlassian Bamboo, JetBrains Teamcity) Sunday 1 February 2009
  • 48. Pequeno twist - Buildr • Maven para quem é cool • Escreve-se em Ruby no lugar de XML • Usa mesmo layout e repositórios que maven • Mas não é directo passar de POM para buildfile • Menos declarativo, mais poderoso Sunday 1 February 2009
  • 49. The End Perguntas? Jantar? Ruben Badaró ruben.badaro@gmail.com http://www.zonaj.org Sunday 1 February 2009