Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Enterprise Web App. Development (1): Build Tool Training

Enterprise Web App. Development (1): Build Tool Training

This is the first course of a series of the courses for Enterprise Web Application development based on several Open Source products. As open source development tools, we are going to take care of Apache Maven as a build tool, Git as a version control tool and JUnit5 as a test tool. After then, we are going into the Jakarta EE framework. Therefore this series require the basic skills of Windows 10, CentOS, Eclipse IDE, Java SE (Oracle JDK, Open JDK), Payara Server and PostgreSQL. Regarding the Payara Server, we can use another Web Application Server conforming to Jakarta EE specification. As for PostgreSQL, we might be able to use another RDBMS product instead. We can also make use of another Linux distribution instead of CentOS.

E7d0d73badb1cc1df2bc44f58d51aaff?s=128

Koichi NAKAGAWA

November 26, 2020
Tweet

Transcript

  1. BUILD TOOL A part of the Open Source Development Tool

    Courses Using Apache Maven™ with M2Eclipse™ Eclipse™ Plug-in 1 By Koichi NAKAGAWA
  2. Open Source Development Tools Build Tool (Apache Maven™) 2

  3. EWA development course curriculum Object Oriented Development Methodology JSF with

    CDI JPA + JTA with CDI JAX-RS Application Architecture Design Patterns Eclipse IDE™ Version Control Tool with Git™ Build Tool with Apache Maven™ Payara Server™ Administration Windows 10™ + Linux (CentOS™) Total EWA Development Exercise Jakarta Batch Java SE (Oracle JDK™/OpenJDK™) Required Skills to take courses Test Tool with JUnit5 PostgreSQL™ Administration 3
  4. Open Source Development Tools • Build Tool (Apache Maven™ with

    Eclipse™ Plug-in) • Version Control Tool (Git™ with Eclipse™ Plug-in) • Test Tool (JUnit5 with Eclipse™ Plug-in) 4
  5. Trademarks Notice • Apache Maven, Maven and the Maven logo(

    ) are trademarks of the Apache Software Foundation (ASF). • Apache Ant, Ant and the Ant logo( ) are trademarks of the Apache Software Foundation (ASF). • Apache Archiva, Archiva and the Archiva logo( ) are trademarks of the Apache Software Foundation (ASF). • Eclipse IDE for Enterprise Java Developers™, the Eclipse IDE for Enterprise Java Developers™ logo( ) are trademarks of the Eclipse Foundation. • Eclipse M2Eclipse™, M2Eclipse™ is trademark of the Eclipse Foundation. • Java™ is trademark of Oracle Corporation. 5
  6. Assumption for this course • The trainees who take this

    course are required the following skills in advance • Oracle JDK/OpenJDK (Version: 8) • Eclipse IDE for Enterprise Java Developers (Version: 2020-09 (4.17.0)) 6
  7. Objectives of Build Tool Course • Learning the Apache Maven™

    Build Tool, you will obtain the concepts of build tool and how to operate it through M2Eclipse™ Eclipse™ plug-in for Apache Maven™. Additionally you will know how to set up the remote Maven repository environment using Apache Archiva™ and how to use it. 7
  8. Apache Maven™ Build Tool • Concepts • POM (Project Object

    Model) • M2Eclipse™ Eclipse Plug-in • Apache Archiva™ Build Artifact Repository Manager 8
  9. Apache Maven™ Concepts 9

  10. Open Source Build Tools History • Historical Build Tools make

    Unix Standard Build Tool which provides “Build Automation” and “Dependency Management” between target module and required source files. Apache Ant™ Initial Java Standard Build Tool which implements the concepts similar to Unix Standard Build Tool, make tool, but using XML configuration file. Apache Maven™ Advanced Java Standard Build Tool which implements the concept of “Convention over Configuration” and the “Library Management with Automatic Download” feature. Configuration File Makefile build.xml pom.xml 10
  11. Convention over Configuration • Different Approach between Apache Ant™ and

    Apache Maven™ <target name=“init”> <mkdir dir=“target/classes”/> </target> <target name=“compile” depends=“init”> <javac srcdir=“src/main/java” destdir=“target/classes”/> </target> <target name=“package” depends=“compile”> <jar jarfile=“target/abc-0.1.jar” basedir=“target/classes” /> </target> Ant – build.xml <project> <modelVersion>4.0.0</modelVersion> <groupId>org.xyz</groupId> <artifactId>abc</artifactId> <version>0.1</version> </project> Maven – pom.xml Convention over Configuration 11 a software design paradigm used by software frameworks that attempts to decrease the number of decisions that a developer using the framework is required to make without necessarily losing flexibility. (Source: Wikipedia, https://en.wikipedia.org/wiki/Convention_over_configuration)
  12. Convention over Configuration • Default Build Life Cycle and Standard

    Directory Structure of Apache Maven™ compile test package install deploy Artifact Local Repository Remote Repository src main java resources webapp site test java resources target Default Build Life Cycle Standard Directory Structure 12
  13. Convention over Configuration • Goal and Plugin for each Build

    Life Cycle Phase based on a “packaging” tag in pom.xml compile test package install deploy Default Build Life Cycle Phase compile maven-compiler-plugin maven-surefire-plugin test maven-jar-plugin jar maven-install-plugin install maven-deploy-plugin deploy Goal Plugin 13
  14. Convention over Configuration • Example of actual phases, goals, plug-ins

    and tasks for a “jar” packaged artifact Phase Goal Plug-In Task process-resources resource maven-resources-plugin • Copy “src/main/resources” to “target/classes” compile compile maven-compiler-plugin • Compile java source files under “src/main/java” and put the class files under “target/classes” process-test-resources testResourceses maven-resources-plugin • Copy “src/test/resources” to “target/test-classes” test-compile testCompile maven-compiler-plugin • Compile test cases under “src/test/java” and put the class files under “target/test-classes” test test maven-surefire-plugin • Execute compiled test cases and put the outcome under “target/surefire-reports” package jar maven-jar-plugin • Generate the target project package and put it under “target/classes” install install maven-install-plugin • Put the generated package to the local repository deploy deploy maven-deploy-plugin • Put the generated package to the remote repository 14
  15. Library Management with Automatic Download • Automatic Download of Required

    Library Modules Application abc-0.1.jar aaa-2.1.1.jar bbb-5.2.jar <project> : <dependencies> <dependency> <groupId>org.xyz</groupId> <artifactId>abc</artifactId> <version>0.1</version> <scope>test</scope> </dependency> </dependencies> : </project> . . . . . . Maven– pom.xml Local Repository org xyz abc-0.1.jar internet Central Repository Automatic Download at “test” phase 15
  16. Apache Maven™: Project Object Model (POM) 16

  17. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (1) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>model version</modelVersion> <groupId>group id</groupId> <artifactId>artefact id</artifactId> <version>version</version> <packaging>package type</packaging> : </project> POM version (Currently only “4.0.0” is supported) Artifact Id (Project Name: a part of the target package) Group Id (Unique Id among an organization or a project) Version (Project Version: a part of the target package) Package Format like “jar”(default), “war”, “ear”, “pom” 17
  18. Project Object Model (pom.xml) • Project Folder/Local Repository Example based

    on Standard Maven Task Flow Local Repository com xyz apptest-0.0.1.jar compile install Project Folder src main java (com.xyz) App.java target classes (com.xyz) App.class package Project Folder src main java (com.xyz) App.java target apptest- 0.0.1.jar classes (com.xyz) App.class 18 Exercise: Let’s make a pom.xml for the above example.
  19. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (1) Example <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.xyz</groupId> <artifactId>apptest</artifactId> <version>0.0.1</version> <packaging>jar</packaging> : </project> 19
  20. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (2) - Properties <project xmlns="http://maven.apache.org/POM/4.0.0" … > : <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> : <dummy>dummy-value</dummy> : </properties> : </project> maven-compiler-plugin This value can be referred as ${dummy} in pom.xml The JDK version in current use is “source” and the target JDK version is “target” A character encoding scheme like “UTF-8”, “UTF-16”, “ASCII” to read and write files with plug-ins 20
  21. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (3) – Artifact Dependency Management <project xmlns="http://maven.apache.org/POM/4.0.0" … > : <dependencies> : <dependency> <groupId>group id</groupId> <artifactId>artifact id</artifactId> <version>version</version> <type>package type</type> <scope>scope</scope> </dependency> : </dependencies> : </project> Packaging type (default: jar) Dependent artifact is specified. 21
  22. Project Object Model (pom.xml) • Artifact Dependency Example of automatic

    downloaded artifact in Local Repository Central Repository junit junit-4.12.jar internet Local Repository junit junit-4.12.jar <dependencies> : <dependency> <groupId>?</groupId> <artifactId>?</artifactId> <version>?</version> <type>?</type> <scope>test</scope> </dependency> : </dependencies> 22 Exercise: Let’s make a pom.xml for the above example.
  23. Project Object Model (pom.xml) • Artifact Dependency Example of automatic

    downloaded artifact in Local Repository Central Repository junit junit-4.12.jar internet Local Repository junit junit-4.12.jar <dependencies> : <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <type>jar</type> <scope>test</scope> </dependency> : </dependencies> 23
  24. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (3) – Artifact Dependency Management (<scope>) When? Scope Compile Test Execution compile (default)    provided   runtime   test  system   <scope> in <dependency> indicates when the dependent module is added to classpath. Show if the dependent module is included in the artifact. (Example) Jakarta EE container modules. (Example) JRE system modules. 24
  25. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (3) – Artifact Dependency Management (<scope>) compile provided runtime test compile compile runtime provided provided provided runtime runtime runtime test test test <scope> in <dependency> also indicates how to deal with “Transitive Dependency”. Artifact B Artifact A Project runtime (“Transitive Dependency”) compile runtime 25 Artifact A’s Scope for Project Artifact B’s Scope for Artifact A
  26. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (3) – Artifact Dependency Management (<version>) 1.0 : “Soft” requirement on 1.0 [1.0] : “Hard” requirement on 1.0 [1.0,) : x >= 1.0 (,1.0] : x <= 1.0 [1.0, 2.0] : 1.0 <= x <= 2.0 [1.0, 2.0) : 1.0 <= x < 2.0 (,1.0],[2.0,) : x <= 1.0 or x >= 2.0 (,1.1),(1.1,) : Exclude 1.1 <version> in <dependency> also indicates which version of dependent module is used. “alpha” < “beta” < “milestone” < “rc” = “cr” < “SNAPSHOT” < “” = “final” = “ga” < “sp” Ex. “1.ga” = “1.final” “1-alpha-1” < “1-SNAPSHOT” 26
  27. Project Object Model (pom.xml) • Artifact Dependency Example of <scope>

    and <version> Target Project org.abc.helloApp Project org.xyz.byeApp Project Direct Dependency Scope: compile Version: 2.53 Only Direct Dependency Scope: runtime Version: >= 3.4 Dependency for Project What Scope? When Used? WhichVersion? Example Artifact org.abc.helloApp compile Compile/Test/Execution 2.53 Only org.abc.helloApp_2.53.jar org.xyz.byeApp runtime Test/Execution X >= 3.4 org.xyz.byeApp_5.6.jar Target Project is dependent on the following artifacts Transitively Dependency Scope: runtime Version: >= 3.4 <dependency> <groupId>?</groupId> <artifactId>?</artifactId> <version>?</version> <type>?</type> <scope>?</scope> </dependency> <dependency> <groupId>?</groupId> <artifactId>?</artifactId> <version>?</version> <type>?</type> <scope>?</scope> </dependency> 27 Exercise: Let’s make the <dependency> tags for the Target and helloApp Projects.
  28. Project Object Model (pom.xml) • Artifact Dependency Example of <scope>

    and <version> <dependency> <groupId>org.abc</groupId> <artifactId>helloApp</artifactId> <version>[2.53]</version> <type>jar</type> <scope>compile</scope> </dependency> < Target Project> <dependency> <groupId>org.xyz</groupId> <artifactId>byeApp</artifactId> <version>[3.4,)</version> <type>jar</type> <scope>runtime</scope> </dependency> < helloApp Project> Target Project helloApp Project byeApp Project Direct Dependency Compile scope Direct Dependency Runtime scope Transitive Dependency Runtime scope 28
  29. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (4) – Inheritance Several projects can share the configuration of their parent’s pom. Parent POM Child POM #1 Child POM #2 Child POM #3 <project … > <modelVersion> 4.0.0 </modelVersion> <group>…</group> <artifactId>…</artifactId> <version>…</version> <packaging>pom</packaging> (Common Elements) and (Elements to configure values) </project> ex. <dependencyManagement> <project … > <modelVersion> 4.0.0 </modelVersion> <parent> <group>…</group> <artifactId>…</artifactId> <version>…</version> <relativePath>../my-parent</relativePath> </parent> </project> Super POM my-parent (Relative Path to Parent Project directory from Child Projects) /projects/my-parent/pom.xml < Parent POM> /projects/child1/pom.xml /projects/child2/pom.xml /projects/child3/pom.xml < Child POMs> 29
  30. Project Object Model (pom.xml) • pom packaging Inheritance Example Several

    projects can share the configuration of their parent’s pom. Super POM Parent POM Child POM Depend on “org.abc.helloApp-2.53.jar” in “compile” scope Depend on “com.xyz.abcxyz-1.21.jar” in “compile” scope com.xyz.my-parent-5.2.pom /projects/my-parent/pom.xml < Parent POM> /projects/my-project/pom.xml < Child POM> Shared Part Specific Part com.xyz.my-project-1.1.jar 30 Exercise: Let’s make 2 pom.xml for the Parent and Child Projects.
  31. Project Object Model (pom.xml) • pom packaging Inheritance Example using

    <parent> and <relative-path> <project … > <modelVersion> 4.0.0 </modelVersion> <group>com.xyz</group> <artifactId>my-parent</artifactId> <version>5.2</version> <packaging>pom</packaging> <dependencies> <dependency> <groupId>org.abc</groupId> <artifactId>helloApp</artifactId> <version>2.53</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies> </project> <project … > <modelVersion> 4.0.0 </modelVersion> <group>com.xyz</group> <artifactId>my-project</artifactId> <version>1.1</version> <parent> <group>com.xyz</group> <artifactId>my-parent</artifactId> <version>5.2</version> <relativePath>../my-parent</relativePath> </parent> <dependencies> <dependency> <groupId>com.xyz</groupId> <artifactId>abcxyz</artifactId> <version>1.21</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies> </project> Shared Part < Parent POM> < Child POM > Specific Part Parent POM 31
  32. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (5) – Aggregation Parent POM comprises multiple Child POMs. Parent POM Child POM #1 Child POM #2 Child POM #3 <project … > <modelVersion> 4.0.0 </modelVersion> <group>…</group> <artifactId>…</artifactId> <version>…</version> <packaging>pom</packaging> <modules> <module>my-project</module> <module>another-project</module> <module>third-project</module> </modules> </project> my-project another-project third-project (The Child POM directory paths relative to the Parent POM directory) /projects/pom.xml /projects/my-project/pom.xml /projects/another-project/pom.xml /projects/third-project/pom.xml < Parent POM> < Children POM> 32
  33. Project Object Model (pom.xml) • pom packaging Aggregation Example Parent

    POM comprises multiple Child POMs. Parent POM Child POM #1 Child POM #2 Child POM #3 my-project another-project third-project Depend on “com.xyz.another-project-2.21.jar” in “compile” scope /projects/pom.xml /projects/my-project/pom.xml /projects/another-project/pom.xml /projects/third-project/pom.xml < Parent POM> < Children POM> com.xyz.my-parent-5.2.pom com.xyz.my-project-1.1.jar 33 Exercise: Let’s make 2 pom.xml for the Parent and Child Projects. com.xyz.another-project-2.21.jar com.xyz.third-project-5.34.jar
  34. Project Object Model (pom.xml) • pom packaging Aggregation Example using

    <modules> and <module> <project … > <modelVersion> 4.0.0 </modelVersion> <group>com.xyz</group> <artifactId>my-parent</artifactId> <version>5.2</version> <packaging>pom</packaging> <modules> <module>my-project</module> <module>another-project</module> <module>third-project</module> </modules> </project> <project … > <modelVersion> 4.0.0 </modelVersion> <group>com.xyz</group> <artifactId>my-project</artifactId> <version>1.1</version> <dependencies> <dependency> <groupId>com.xyz</groupId> <artifactId>another-project</artifactId> <version>2.21</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies> </project> Children Definition < Parent POM> < Child POM #1 (my-project) > Dependency to another child 34
  35. Project Object Model (pom.xml) • pom.xml: Maven Project File (XML)

    (6) – Build and Profile <build> is used to change default Maven behaviors or add some behaviors. <profile> is used to define multiple customized configurations in a pom.xml file. <project … > <modelVersion> 4.0.0 </modelVersion> <group>com.xyz</group> <artifactId>my-project</artifactId> <version>1.4</version> <build> … </build> <profiles> <profile> <build> … </build> </profile> : </profiles> </project> Project Build 35 Profile Definitions Multiple <profile> definitions in pom.xml pom.xml Profile A (Deploy war file to Local WAS) Profile B (Deploy war file to Remote WAS) Profile X . . .
  36. Project Object Model (pom.xml) • Example changing a default behavior

    of Maven to change artifact file name <project> <modelVersion> 4.0.0 </modelVersion> <groupId>com.xyz</groupId> <artifactId>projectA</artifactId> <version>2.3</version> <packaging>war</packaging> : </project> Actual File Name: projectA.war Maven Default File Name: projectA-2.3.war 36 Exercise: Let’s make a pom.xml for the above example.
  37. Project Object Model (pom.xml) • Example changing a default behavior

    of Maven using <build> and <finalName> <project> <modelVersion> 4.0.0 </modelVersion> <group>com.xyz</group> <artifactId>projectA</artifactId> <version>2.3</version> <packaging>war</packaging> <build> <finalName>projectA</finalName> </build> </project> Actual File Name: projectA.war Maven Default File Name: projectA-2.3.war 37
  38. Apache Maven™: M2Eclipse™ Eclipse Plug-in 38

  39. M2Eclipse™ • M2Eclipse™(Maven Plug-in for Eclipse IDE) M2Eclipse™ is a

    Maven Plug-in for Eclipse and bundled into Eclipse IDE for Enterprise Java Developers™ 39
  40. M2Eclipse™ • M2Eclipse™(Maven Plug-in for Eclipse IDE) Eclipse IDE for

    Enterprise Java Developer™ PC Local Repository internet Central Repository M2Eclipse™ M2Eclipse™ takes care of most of Maven operations including automatic downloading from Central Repository, installing to Local Repository. 40
  41. How to use M2Eclipse™? • Procedures to develop a Maven

    Project with M2Eclipse™ Make Maven Project Test Project Test Case Build Project Package Run Project Application 41
  42. • What’s Archetype?  Archetype generates pom.xml, Maven Directory Structure

    with some files to be used as templates  Developer selects an Artifact from Archetype Catalogs for specific Maven Project Type How to use M2Eclipse™ Make Maven Project 42 src main java resources webapp site test java resources pom.xml pom.xml and Maven Directory Structure Archetype Generate Archetype Catalogs Select Artifact
  43. How to use M2Eclipse™? • Sample procedures to develop a

    Maven Project with M2Eclipse™ on Eclipse 4.10.0 Create Maven Project - Group Id: org.example - Artifact Id: simple - Version: 0.0.1 - Type: jar Make Maven Project Test Project Test Case Build simple-0.0.1.jar package Build Project Package Execute org.example.simple App.java Execute JUnit for org.example.simple AppTest.java Run Project Application org.apache.maven.archetypes maven-archetype-simple ver1.4 Archetype 43 Exercise: Let’s make a Maven project following the above sample procedure.
  44. • Create a new workplace named “ws1” 1. After executing

    Eclipse™, click “File  Switch Workspace  Other…” 2. “Select a directory as a workspace” dialog menu comes up and click “Browse…”. 3. “Select Workspace Directory” dialog menu comes up and create a new workspace folder named “ws1” by clicking “New folder” button and select it as Workspace and click “Select Folder”. 4. Click “Launch” button and Eclipse is restarted with the new workplace. How to use M2Eclipse™ 44
  45. • Configure Installed JRE (1) 1. Select “Window  Preferences”

    and “Preferences” dialog menu comes up. 2. Select “Java  Installed JREs” and click “Add …” button. How to use M2Eclipse™ 45
  46. • Configure Installed JRE (2) 3. Select “Standard VM” and

    click “Next >” button and “Add JRE” dialog menu comes up. 4. Click “Directory …” button and select an installed JDK home directory and click “Finish” button. How to use M2Eclipse™ 46
  47. • Configure Installed JRE (3) 5. Select the added JDK

    entry from “Installed JREs” and click “Apply and Close” button. How to use M2Eclipse™ 47
  48. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (1) From the Project Explore pane, click the “Create a Maven project” link. How to use M2Eclipse™ Make Maven Project 48
  49. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (2) From “New Maven project” dialog menu, check “Use default Workplace location” and click “Next >” button How to use M2Eclipse™ Make Maven Project 49
  50. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (3) Click “Configure…” next to Catalog, if “maven-archetype-simple (Ver. 1.4)” does NOT exist in the Archetype list. Otherwise, skip the next few steps. How to use M2Eclipse™ Make Maven Project If “maven-archetype-simple (Ver. 1.4)” already exists, skip this step. 50
  51. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (4) Click “Add Remote Catalog …” next to Catalog How to use M2Eclipse™ Make Maven Project 51 If “maven-archetype-simple (Ver. 1.4)” already exists, skip this step.
  52. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (5) Enter “http://repo.maven.apache.org/maven2/archetype-catalog.xml” as Catalog File and “Remote Catalog” as Description and click “OK” button How to use M2Eclipse™ Make Maven Project 52 If “maven-archetype-simple (Ver. 1.4)” already exists, skip this step.
  53. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (6) Click “Apply and Close” button How to use M2Eclipse™ Make Maven Project 53 If “maven-archetype-simple (Ver. 1.4)” already exists, skip this step.
  54. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (7) From “Select an Archetype” dialog menu, select “Remote Catalog” or “All Catalogs” in Catalog field and “org.apache.maven.archetypes maven-archetype-simple 1.4” and click “Next >” button How to use M2Eclipse™ Make Maven Project 54
  55. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (8) From “New Maven project” dialog menu, enter a Group Id of “org.example” and a Artifact Id of “simple” and a Version of “0.0.1” and click “Finish” button How to use M2Eclipse™ Make Maven Project 55
  56. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (9) Confirm that the following Maven project “simple” was created successfully. After that, change compiler version to “1.8” How to use M2Eclipse™ Make Maven Project Change to “1.8” 56
  57. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (10) Modify the App.java of package “org.example.simple” under src/main/java folder like the followings. How to use M2Eclipse™ Make Maven Project App.java AppTest.java Add 57
  58. • Sample Procedure to make a simple Maven project with

    M2Eclipse™ (11) 1. Right click on “simple” project and select “Maven  Update Project …” 2. “Update Maven Project” dialog menu comes up and select “simple” Codebase and click “OK” button. How to use M2Eclipse™ Make Maven Project 58
  59. • Sample Procedure to test the simple Maven project with

    JUnit (1) Right click on the “simple” project and select “Run As”  “2 JUnit Test” How to use M2Eclipse™ Test Project Test Case 59
  60. • Sample Procedure to test the simple Maven project with

    JUnit (2) Confirm that the result is shown as “Green Flag” which means JUnit finished successfully How to use M2Eclipse™ Test Project Test Case 60
  61. • Sample Procedure to build the simple Maven project with

    M2Eclipse™ (1) Right click on the “simple” project and select “Run As”  “3 Maven Build” How to use M2Eclipse™ Build Project Package 61
  62. • Sample Procedure to build the simple Maven project with

    M2Eclipse™ (2) Enter “Package simple” as Name and “clean package” in the Goal field and click “Run” button How to use M2Eclipse™ Build Project Package 62
  63. • Sample Procedure to build the simple Maven project with

    M2Eclipse™ (3) Confirm the “BUILD SUCCESS” message on the console How to use M2Eclipse™ Build Project Package 63
  64. • Sample Procedure to execute the simple Maven project (1)

    Right click on the “simple” project and select “Run As”  “1 Java Application” How to use M2Eclipse™ Run Project Application 64
  65. • Sample Procedure to execute the simple Maven project (2)

    From “Select Java Application” dialog menu, select “App – org.example.simple” and click “OK” button How to use M2Eclipse™ Run Project Application 65
  66. • Sample Procedure to execute the simple Maven project (3)

    Confirm that the result is shown as below successfully on console How to use M2Eclipse™ Run Project Application 66
  67. Apache Maven™: Apache Archiva™ Build Artifact Repository Manager 67

  68. Apache Archiva™ • Apache Archiva™: Build Artifact Repository Manager Eclipse

    IDE for Enterprise Java Developer™ PC Apache Archiva™ Remote Repository Local Repository Server internet Central Repository Eclipse IDE for Enterprise Java Developer™ PC Local Repository . . M2Eclipse™ M2Eclipse™ 68
  69. Team Development • Team Development with Apache Archiva™ Development Team

    A (xxx.jar) Development Team B (yyy.jar) Development Team C (zzz.war) Apache Archiva™ Remote Repository Server deploy deploy deploy pull pull pull - xxx.jar - yyy.jar - zzz.war Depend Depend 69
  70. Standalone (Simple Installation) Work on Apache Tomcat™ (Additional Installations Required)

    Installation of Apache Archiva™ • 2 Ways of Apache Archiva™ Installation Apache Archiva™ Derby™ Database Server Jetty™ Web App Server Apache Archiva™ Derby™ Database Server Tomcat™ Web App Server Install Archiva™ war file on Tomcat™ and additional tasks are required to set up Just extract an Archiva™ archival file 70
  71. Development with Apache Archiva™ • Configurations to make use of

    Apache Archiva™ from M2Eclipse™ Configuration File settings.xml pom.xml Location $HOME/.m2/settings.xml $PROJECT/pom.xml Role Common Part of Maven Configuration for all projects Project Specific Part of Maven Configuration for a project Descriptions How to retrieve artifacts from Archiva™ -Release Artifacts from Internal Repository -Snapshot Artifacts from Snapshots Repository -Plug-in Artifacts from Internal Repository How to deploy artifacts to Archiva™ -Release Artifacts to Internal Repository -Snapshot Artifacts to Snapshots Repository M2Eclipse™ Apache Archiva™ Internal Repository Snapshots Repository - Release Artifacts - Plug-in Artifacts - Snapshot Artifacts 71
  72. How to install and configure Apache Archiva™? • Procedures to

    make use of Apache Archiva™ 2.2.5 Installation of Apache Archiva™ Configure Fetch Configure Deployment 72
  73. Installation of Apache Archiva™ • How to install Apache Archiva™

    1. Download Apache Archiva™ 2.2.5 Standalone Server archive file from http://archiva.apache.org/download.cgi 2. Create an Archiva User #useradd archiva 3. Extract the downloaded archive file and change the ownership of the extracted files #cp apache-archiva-2.2.5-bin.zip /opt #cd /opt #unzip apache-archiva-2.2.5-bin.zip #chown -R archiva:archiva apache-archiva-2.2.5 #rm apache-archiva-2.2.5-bin.zip 4. (Option) To change port number, edit /opt/apache-archiva-2.2.5/conf/jetty.xml <Set name="port"><SystemProperty name="jetty.port" default=“[new port number]"/></Set> 5. Configure firewall #firewall-cmd --add-port=[new port number]/tcp #firewall-cmd --runtime-to-permanent Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 Installation of Apache Archiva™ (Assumption: Oracle JDK/OpenJDK version 8 must be installed before installing Apache Archiva™. JDK 11 is not supported yet.) 73
  74. Installation of Apache Archiva™ • How to install Apache Archiva™

    6. Configure auto-startup & shutdown 1) Create /etc/systemd/system/archiva.service file including the following contents. [Unit] Description = Apache Archiva 2.2.5 Standalone Server After = syslog.target network.target [Service] User=archiva ExecStart = /usr/bin/sh /opt/apache-archiva-2.2.5/bin/archiva start ExecStop = /usr/bin/sh /opt/apache-archiva-2.2.5/bin/archiva stop ExecReload = /usr/bin/sh /opt/apache-archiva-2.2.5/bin/archiva restart Type = forking [Install] WantedBy = multi-user.target 2) Enable auto-startup & shutdown #systemctl daemon-reload #systemctl enable archiva.service 7. Start Apache Archiva™ Server #systemctl start archiva.service Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 74
  75. Installation of Apache Archiva™ • How to install Apache Archiva™

    1. Download Apache Archiva™ 2.2.5 Standalone Server archive file from http://archiva.apache.org/download.cgi 2. Extract the downloaded archive file to C:\usr\local\ 3. (Option) To change port number, edit C:\usr\local\apache-archiva-2.2.5\conf\jetty.xml <Set name="port"><SystemProperty name="jetty.port" default=“[new port number]"/></Set> 4. Install the Apache Archiva as a Windows’ service Open Command Prompt as Administrator and execute the following command. C:\WINDOWS\system32>cd \usr\local\apache-archiva-2.2.5 C:\usr\local\apache-archiva-2.2.5>bin\archiva.bat install 5. Start the Apache Archiva service with traditional Windows Service console Procedure to install Apache Archiva™ 2.2.5 Standalone Server on Windows 10 Installation of Apache Archiva™ (Assumption: Oracle JDK/OpenJDK version 8 must be installed before installing Apache Archiva™. JDK 11 is not supported yet.) 75
  76. Installation of Apache Archiva™ • How to configure Apache Archiva™

    1. Set password admin account 1) Access to Apache Archiva™ Server with a browser at http://<Server Host Name>:[new port number]/ 2) Click “Create Admin User” button 3) Set “Password” and “Email” of admin account and “Validated” option and click “Save” button 2. Add an Account for Maven Clients like M2Eclipse™ 1) Login as admin 2) Select “USERS”  “Manage” menu and select “Add” tab Enter “Username”, “Password”, “Email” and set “Validated” option and click “Save” button 3) Select “USERS”  “Manage” menu and click “Edit” button for the account created above Click “Edit Roles” menu and select “Registered User” and “Repository Manager / Repository Observer” for both “snapshots” and “internal” repositories. 3. (Option) Disable Expiration feature for accounts 1) Login as admin 2) Select “Users Runtime Configuration” -> “Properties” 3) Set “false” for “security.policy.password.expiration.enabled” and click “Save” button Procedure to configure Apache Archiva™ 2.2.5 Standalone Server Installation of Apache Archiva™ 76
  77. Installation of Apache Archiva™ • How to configure Apache Archiva™

    4. (Option) Disable “Block Redeployments” feature for “Internal Repository” 1) Login as admin 2) Select “Repositories” 3) Click “Edit” icon for the “Internal Repository” 4) Uncheck “Block Redeployments” and click “Save” button Procedure to configure Apache Archiva™ 2.2.5 Standalone Server (Continued) Installation of Apache Archiva™ 77
  78. Maven Configuration for Apache Archiva™ • How to configure Apache

    Archiva™ account in $HOME/.m2/settings.xml <?xml version="1.0"?> <settings> <servers> <server> <id>repository-release</id> <username>[User Name]</username> <password>[Password]</password> </server> <server> <id>repository-snapshot</id> <username>[User Name]</username> <password>[Password]</password> </server> </servers> : Define Account to access Apache Archiva™ for RELEASE Repository $HOME/.m2/settings.xml Configure Fetch Define Account to access Apache Archiva™ for SNAPSHOT Repository 78
  79. Maven Configuration for Apache Archiva™ • How to configure Apache

    Archiva™ profile in $HOME/.m2/settings.xml : <profiles> <profile> <id>Repository Proxy</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> … </repositories> <pluginRepositories> … </<pluginRepositories> </profile> </profiles> </settings> $HOME/.m2/settings.xml (Continued) Define a Profile for Apache Archiva™ Configure Fetch 79
  80. Maven Configuration for Apache Archiva™ • How to configure the

    Release Repository in $HOME/.m2/settings.xml <repositories> <repository> <id>repository-release</id> <name>Archiva Managed Internal Repository</name> <url>http://<Archiva host name>: <port>/repository/internal/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> Retrieve “RELEASE” version of dependent modules from Archiva™ $HOME/.m2/settings.xml (<repositories> part) Configure $HOME/.m2/settings.xml Configure Fetch 80
  81. Maven Configuration for Apache Archiva™ • How to configure the

    Snapshots Repository in $HOME/.m2/settings.xml <repository> <id>repository-snapshot</id> <name>Archiva Managed Snapshots Repository</name> <url>http://<Archiva host name>: <port>/repository/snapshots/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> Retrieve “SNAPSHOT(Under Developmen)” Version like <version>1.0-SNAPSHOT</version> $HOME/.m2/settings.xml (<repositories> part) (Continued) Configure $HOME/.m2/settings.xml Configure Fetch 81
  82. Maven Configuration for Apache Archiva™ • How to configure the

    Plug-In Repository in $HOME/.m2/settings.xml <pluginRepositories> <pluginRepository> <id>repository-release</id> <name>Archiva Managed Internal Repository</name> <url>http://<Archiva host name>:<port>/repository/internal/</url> </pluginRepository> </pluginRepositories> Retrieve Plug-In modules from Apache Archiva™ $HOME/.m2/settings.xml (<pluginRepositories> part) Configure $HOME/.m2/settings.xml Configure Fetch 82
  83. Selection of fetched repository type • How to select the

    RELEASE repository of Apache Archiva™ Server <dependencies> <dependency> <groupId>org.abc</groupId> <artifactId>helloApp</artifactId> <version>2.53</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies> Retrieve the dependent module from RELEASE repository of Archiva™ Server $PROJECT/pom.xml Configure $HOME/.m2/settings.xml Configure Fetch 83
  84. Selection of fetched repository type • How to select the

    SNAPSHOT repository of Apache Archiva™ Server <dependencies> <dependency> <groupId>org.abc</groupId> <artifactId>helloApp</artifactId> <version>2.53-SNAPSHOT</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies> Retrieve the dependent module from SNAPSHOT repository of Archiva™ Server $PROJECT/pom.xml Configure $HOME/.m2/settings.xml Configure Fetch 84
  85. Package Artifact with Apache Archiva™ • How to fetch artifacts

    from Apache Archiva™ with M2Eclipse™ Right click on project  “Run As”  “4. Maven Build …” Configure Fetch 85 compile test package
  86. Maven Configuration for Apache Archiva™ • How to configure pom.xml

    for deploying developed modules to Apache Archiva™ <project> <distributionManagement> <repository> <id>repository-release</id> <name>Internal Release Repository</name> <url>http://<Archiva host name>: <port>/repository/internal/</url> </repository> <snapshotRepository> <id>repository-snapshot</id> <name>Internal Snapshot Repository</name> <url>http://<Archiva host name>: <port>/repository/snapshots/</url> </snapshotRepository > </distributionManagement> </project> Deploy developed SNAPSHOT artifacts to Apache Archiva™ Deploy developed RELEASE artifacts to Apache Archiva™ $PROJECT/pom.xml Configure Deployment 86
  87. Selection of deployed repository type • How to select the

    RELEASE repository to deploy modules to Apache Archiva™ <project …> <modelVersion>4.0.0</modelVersion> <groupId>com.xyz</groupId> <artifactId>apptest</artifactId> <version>0.0.1</version> <packaging>jar</packaging> : </project> Deploy to the RELEASE repository of Archiva™ Server $PROJECT/pom.xml Configure Deployment 87
  88. Selection of deployed repository type • How to select the

    SNAPSHOT repository to deploy modules to Apache Archiva™ <project …> <modelVersion>4.0.0</modelVersion> <groupId>com.xyz</groupId> <artifactId>apptest</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> : </project> Deploy to the SNAPSHOT repository of Archiva™ Server $PROJECT/pom.xml Configure Deployment 88
  89. Deploy Artifact with Apache Archiva™ • How to deploy developed

    an artifact to Apache Archiva™ with M2Eclipse™ Right click on project  “Run As”  “4. Maven Build …” compile test package install deploy Configure Deployment 89
  90. CentOS 8 (Host Name: hostA) Example of M2Eclipse™ Configurations Apache

    Archiva™ Jetty Server (Port: 9090) • Example to install Apache Archiva™ server Install Apache Archiva™ 2.2.5 on CentOS8 server using “9090” as port number and “archiva” as Archiva User and create an Apache Archiva™ account for the developers using “developer” as Username and “dev333” as Password and “developer@xxx.com” as Email Address Configure Deployment Apache Arvhiva™ User: “archiva” Username: developer Password: dev333 Email Address: developer@xxx.com Apache Archiva™ Account 90 Exercise: Let’s install Apache Archiva based on the above information.
  91. Installation of Apache Archiva™ • How to install Apache Archiva™

    1. Download Apache Archiva™ 2.2.5 Standalone Server archive file from http://archiva.apache.org/download.cgi 2. Create an Archiva User #useradd archiva 3. Extract the downloaded archive file and change the ownership of the extracted files #cp apache-archiva-2.2.5-bin.zip /opt #cd /opt #unzip apache-archiva-2.2.5-bin.zip #chown -R archiva:archiva apache-archiva-2.2.5 #rm apache-archiva-2.2.5-bin.zip 4. To change port number, edit /opt/apache-archiva-2.2.5/conf/jetty.xml <Set name="port"><SystemProperty name="jetty.port" default=“9090"/></Set> 5. (Option) Configure firewall, if port 9090 is not open to outside #firewall-cmd --add-port=9090/tcp --runtime-to-permanent 6. Check firewall configuration #firewall-cmd --list-all Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 Installation of Apache Archiva™ (Assumption: Oracle JDK /OpenJDK version 8 must be installed before installing Apache Archiva™. JDK 11 is not supported yet.) 91
  92. Installation of Apache Archiva™ • How to install Apache Archiva™

    7. Configure auto-startup & shutdown 1) Create /etc/systemd/system/archiva.service file including the following contents. [Unit] Description = Apache Archiva 2.2.5 Standalone Server After = syslog.target network.target [Service] User=archiva ExecStart = /usr/bin/sh /opt/apache-archiva-2.2.5/bin/archiva start ExecStop = /usr/bin/sh /opt/apache-archiva-2.2.5/bin/archiva stop ExecReload = /usr/bin/sh /opt/apache-archiva-2.2.5/bin/archiva restart Type = forking [Install] WantedBy = multi-user.target 2) Enable auto-startup & shutdown #systemctl daemon-reload #systemctl enable archiva.service 8. Start Apache Archiva™ Server #systemctl start archiva.service Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 92
  93. Installation of Apache Archiva™ • How to install Apache Archiva™

    8. Set information admin account 1) Access to Apache Archiva™ Server with a browser at http://hostA:9090/ 2) Click “Create Admin User” button Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 93
  94. Installation of Apache Archiva™ • How to install Apache Archiva™

    8. Set information admin account (Continued) 3) Set “Password” and “Email Address” of admin account and “Validated” option and click “Save” button Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 94
  95. Installation of Apache Archiva™ • How to install Apache Archiva™

    9. Add an Account for Maven Clients like M2Eclipse™ 1) Login as admin 2) Select “USERS”  “Manage” menu and select “Add” tab 3) Enter “developer” as Username, “dev333” as Password, “developer@xxx.com” as Email Address and “Validated” option and click “Save” button Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 95
  96. Installation of Apache Archiva™ • How to install Apache Archiva™

    9. Add an Account for Maven Clients like M2Eclipse™ (Continued) 4) Select “USERS”  “Manage” menu and click “Edit” button for the account created just before and click “Edit Roles” menu Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 96
  97. Installation of Apache Archiva™ • How to install Apache Archiva™

    9. Add an Account for Maven Clients like M2Eclipse™ (Continued) 5) Select “Repository Manager” and “Repository Observer” for both “snapshots” and “internal” repositories 6) Click “Update” button Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 97
  98. Installation of Apache Archiva™ • How to install Apache Archiva™

    10. Disable Expiration feature for accounts 1) Login as admin 2) Select “Users Runtime Configuration” -> “Properties” 3) Set “false” for “security.policy.password.expiration.enabled” and click “Save” button Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 98
  99. Installation of Apache Archiva™ • How to install Apache Archiva™

    11. Disable “Block Redeployments” feature for the “RELEASE” repository 1) Login as admin 2) Select “Repositories” and click “Edit” icon for the “Internal Repository” 3) Uncheck “Block Redeployments” and click “Save” button Procedure to install Apache Archiva™ 2.2.5 Standalone Server on CentOS 8 (Continued) Installation of Apache Archiva™ 99
  100. Example of M2Eclipse™ Configurations PC Apache Archiva™ RELEASE Repository Server

    (Host Name: hostA) (Port: 9090) • The way to deploy a developed module to Apache Archiva™ with M2Eclipse™ Deployed Module (Target Artifact): org.example.simple-0.0.1.jar org.example.simple-0.0.1.jar Configure Deployment Eclipse IDE for Enterprise Java Developer™ Local Repository M2Eclipse™ $HOME/.m2/settings.xml $PROJECT/pom.xml Project: org.example.simple 100 Exercise: Let’s deploy the target artifact to Apache Archiva™ based on the above information.
  101. Maven Configuration for Apache Archiva™ • Configure Apache Archiva™ account

    in $HOME/.m2/settings.xml <?xml version="1.0"?> <settings> <servers> <server> <id>repository-release</id> <username>developer</username> <password>dev333</password> </server> <server> <id>repository-snapshot</id> <username>developer</username> <password>dev333</password> </server> </servers> : $HOME/.m2/settings.xml Specify username and password of Archiva™ account Specify username and password of Archiva™ account Configure Deployment 101
  102. Example of M2Eclipse™ Configurations • Deploy org.example.simple-0.0.1.jar to the RELEASE

    repository of Archiva™ Server <project …> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>simple</artifactId> <version>0.0.1</version> <packaging>jar</packaging> : Deploy to the RELEASE repository of Archiva™ Server simple/pom.xml Configure Deployment 102
  103. Example of M2Eclipse™ Configurations • Configure pom.xml for deploying a

    developed module to Archiva™ Server : <distributionManagement> <repository> <id>repository-release</id> <name>Internal Release Repository</name> <url>http://hostA:9090/repository/internal/</url> </repository> <snapshotRepository> <id>repository-snapshot</id> <name>Internal Snapshot Repository</name> <url>http://hostA:9090/repository/snapshots/</url> </snapshotRepository > </distributionManagement> </project> simple/pom.xml (Continued…) Specify URL for RELEASE repository of Archiva™ Specify URL for SNAPSHOT repository of Archiva™ Configure Deployment 103
  104. Example of M2Eclipse™ Configurations • With M2Eclipse, Execute deploy (1)

    Configure Deployment Right click on the “simple” project and Select “Run As”  “4 Maven build…” 104
  105. Example of M2Eclipse™ Configurations • With M2Eclipse, Execute deploy (2)

    Configure Deployment Enter “Deploy simple” in Name field and “deploy” in the Goal field and click “Run” button 105
  106. Example of M2Eclipse™ Configurations • With Archiva Console, check the

    deployed project Configure Deployment After login to Archiva, click “Browse” from the left-side menu and traverse “org->example->simple” 106
  107. Example of M2Eclipse™ Configurations Eclipse IDE for Enterprise Java Developer™

    PC Apache Archiva™ RELEASE Repository Local Repository Server (Host Name: hostA) (Port: 9090) M2Eclipse™ $HOME/.m2/settings.xml $PROJECT/pom.xml • The way to retrieve a dependent module from Apache Archiva™ with M2Eclipse™ Dependent Module (Target Artifact): org.example.simple-0.0.1.jar org.example.simple-0.0.1.jar Configure Fetch Project: org.example.simple2 107 Exercise: Let’s fetch the target artifact from Apache Archiva™ based on the above information.
  108. • Make a simple Maven project with M2Eclipse™ (1) From

    Project Explore, right click and select “New”  “Other…” How to use M2Eclipse™ Configure Fetch 108
  109. • Make a simple Maven project with M2Eclipse™ (2) From

    “Select a wizard” dialog menu, select “Maven”  “Maven Project” and click “Next >” button How to use M2Eclipse™ Configure Fetch 109
  110. • Make a simple Maven project with M2Eclipse™ (3) From

    “New Maven project” dialog menu, confirm that “Use default Workspace location” is selected. After then, click “Next >” button How to use M2Eclipse™ Configure Fetch 110
  111. • Make a simple Maven project with M2Eclipse™ (4) From

    “Select an Archetype” dialog menu, select “Remote Catalog” or “All Catalogs” in Catalog field and “org.apache.maven.archetypes maven-archetype-simple 1.4” and click “Next >” button How to use M2Eclipse™ Configure Fetch 111
  112. • Make a simple Maven project with M2Eclipse™ (4) From

    “New Maven project” dialog menu, enter a Group Id of “org.example” and a Artifact Id of “simple2” and a Version of “0.0.1” and click “Finish” button How to use M2Eclipse™ Configure Fetch 112
  113. • Make a simple Maven project with M2Eclipse™ (5) Confirm

    that the following Maven project “simple2” was created successfully and change compiler version to “1.8” How to use M2Eclipse™ Change to “1.8” Configure Fetch 113
  114. • Make a simple Maven project with M2Eclipse™ (6) Edit

    App.java to use a function of the “simple” deployed to Apache Archiva™ remote repository How to use M2Eclipse™ Add to show the message of project “simple” Configure Fetch 114
  115. Maven Configuration for Apache Archiva™ • Configure Apache Archiva™ account

    in $HOME/.m2/settings.xml (1) <?xml version="1.0"?> <settings> <servers> <server> <id>repository-release</id> <username>developer</username> <password>dev333</password> </server> <server> <id>repository-snapshot</id> <username>developer</username> <password>dev333</password> </server> </servers> : $HOME/.m2/settings.xml Configure Fetch Specify username and password of Archiva™ account Specify username and password of Archiva™ account 115
  116. Example of M2Eclipse™ Configurations • Configure settings.xml for how to

    retrieve modules from Apache Archiva™ (1) <profiles> <profile> <id>Repository Proxy</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>repository-release</id> : <url>http://hostA:9090/repository/internal/</url> : </repository> Specify URL for RELEASE repository of Archiva™ $HOME/.m2/settings.xml (<repositories> part) Configure $HOME/.m2/settings.xml Configure Fetch 116
  117. Example of M2Eclipse™ Configurations • Configure settings.xml for how to

    retrieve modules from Apache Archiva™ (2) $HOME/.m2/settings.xml (<repositories> part) Configure $HOME/.m2/settings.xml <repository> <id>repository-snapshot</id> : <url>http://hostA:9090/repository/snapshots/</url> : </repository> </repositories> <pluginRepositories> <pluginRepository> <id>repository-release</id> <name>Archiva Managed Internal Repository</name> <url>http://hostA:9090/repository/internal/</url> </pluginRepository> </pluginRepositories> </profile> <profiles> Specify URL for RELEASE repository of Archiva™ Configure Fetch 117 Specify URL for SNAPSHOT repository of Archiva™
  118. Example of M2Eclipse™ Configurations • Modify pom.xml to retrieve org.example.simple-0.0.1.jar

    from the RELEASE repository of Archiva™ Server <project …> : <dependencies> : <dependency> <groupId>org.example</groupId> <artifactId>simple</artifactId> <version>0.0.1</version> <type>jar</type> <scope>compile</scope> </dependency> : </dependencies> : </project> Retrieve the dependent module from RELEASE repository of Archiva™ Server simple2/pom.xml Configure $HOME/.m2/settings.xml Configure Fetch 118 Add 1 dependency
  119. Example of M2Eclipse™ Configurations • Remove “org.example.simple” folder from the

    local repository With Explore, delete “<User Home>/.m2/repository/org/example/simple” folder to confirm that this project file will be retrieved from Archiva™ Server automatically. Configure Fetch 119
  120. Example of M2Eclipse™ Configurations • With M2Eclipse, Execute build a

    package (1) Right click on the “simple2” project and Select “Run As”  “4 Maven build…” Configure Fetch 120
  121. Example of M2Eclipse™ Configurations • With M2Eclipse, Execute build a

    package (2) Enter “Package simple2” in Name field and “clean package” in the Goal field and click “Run” button Configure Fetch 121
  122. Example of M2Eclipse™ Configurations • Confirm that the folder of

    “org.example.simple” is created again in the local repository With Explore, check “<User Home>/.m2/repository/org/example/simple” folder which holds the project files retrieved from Archiva™ Server automatically Configure Fetch 122
  123. Example of M2Eclipse™ Configurations • With M2Eclipse, Execute the project

    (1) Right click on the “simple2” project and Select “Run As”  “1 Java Application” Configure Fetch 123
  124. Example of M2Eclipse™ Configurations • With M2Eclipse, Execute the project

    (2) Select on the “App – org.example.simple2” and click “OK”, and then confirm the message in “simple” project is shown. Configure Fetch The message in the “simple” project is shown. 124
  125. Exercise 125

  126. Project org.ews.training.buildtool.exercise1 Exercise1 PC Apache Archiva™ RELEASE Repository Server (Host

    Name: hostA) (Port: 9090) • The exercise to create a project and deploy the artifact to Apache Archiva™ with M2Eclipse™ Target Artifact: org.ews.training.buildtool.exercise1-1.1.jar org.ews.training.buildtool.exercise1-1.1.jar Eclipse IDE for Enterprise Java Developer™ Local Repository M2Eclipse™ $HOME/.m2/settings.xml $PROJECT/pom.xml 126
  127. Project org.ews.training.buildtool.exercise2 Exercise2 Eclipse IDE for Enterprise Java Developer™ PC

    Apache Archiva™ RELEASE Repository Local Repository Server (Host Name: hostA) (Port: 9090) M2Eclipse™ $HOME/.m2/settings.xml $PROJECT/pom.xml • The exercise to create a project and retrieve the artifact deployed in the previous exercise1 from Apache Archiva™ with M2Eclipse™ Target artifact: org.ews.training.buildtool.exercise2-1.5.jar org.ews.training.buildtool.exercise1-1.1.jar 127