1 may 31, 2007 Build, test and deploy ADF applications without effort with the use of Maven2 Aino...

Post on 05-Jan-2016

213 views 0 download

Transcript of 1 may 31, 2007 Build, test and deploy ADF applications without effort with the use of Maven2 Aino...

1may 31, 2007

Build, test and deploy ADF applications without effort with the use of Maven2

Aino Andriessen

AMIS

2may 31, 2007

Continuous Integration

Continuous integration is the practice where the work of all the developers are integrated, analyzed and verified on a regular basis, preferably multiple times a day.

It takes the latest situation from the source control system, performs unit tests, makes a build, deploys the application, performs integration tests and creates reports about these steps and communicates them with the team, all automatically without human interaction.

3may 31, 2007

Conditions

InfrastructureScriptingNo IDE

4may 31, 2007

Scripting

Mavenantmakeshell scriptssql scripts ...

5may 31, 2007

Demo

6may 31, 2007

Maven execution info

[INFO] Scanning for projects...[INFO] Reactor build order:[INFO] HR1[INFO] HR1 model[INFO] HR1 viewController[INFO] HR1 ear[INFO] HR1 integration[INFO] -------------------------

Downloading: http://repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar118K downloaded

[INFO][INFO] ------------------------------------------------------------------------[INFO] Reactor Summary:[INFO] ------------------------------------------------------------------------[INFO] HR1 ................................................... SUCCESS [3.003s][INFO] HR1 model ............................................. SUCCESS [7.866s][INFO] HR1 viewController .................................... SUCCESS [54.451s][INFO] HR1 ear ............................................... SUCCESS [14.591s][INFO] HR1 integration ....................................... SUCCESS [0.312s][INFO] ------------------------------------------------------------------------[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESSFUL[INFO] ------------------------------------------------------------------------[INFO] Total time: 1 minute 20 seconds[INFO] Finished at: Fri Jun 01 17:32:01 CEST 2007[INFO] Final Memory: 10M/18M[INFO] ------------------------------------------------------------------------

7may 31, 2007

mvn test

[INFO] [surefire:test][INFO] Surefire report directory: D:\projects\myprojects\odtugDemo\hr1\model\target\surefire-reports------------------------------------------------------- T E S T S-------------------------------------------------------Running nl.amis.demo.odtug.model.queries.OdtugTstViewTestJun 1, 2007 7:04:22 PM oracle.adf.share.config.ADFConfigFactory findOrCreateADFConfigINFO: oracle.adf.share.config.ADFConfigFactory No META-INF/adf-config.xml foundTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.606 secRunning nl.amis.demo.odtug.model.queries.RegionsViewTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 secRunning nl.amis.adf.fwk.test.Java5TestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 secRunning nl.amis.demo.odtug.model.queries.JobsViewTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.046 secRunning nl.amis.demo.odtug.model.queries.EmployeesViewTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.032 secRunning nl.amis.demo.odtug.model.queries.DepartmentsViewTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 secRunning nl.amis.demo.odtug.model.queries.LocationsViewTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 secRunning nl.amis.demo.odtug.model.queries.CountriesViewTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec

Results :

Tests run: 8, Failures: 0, Errors: 0, Skipped: 0

8may 31, 2007

mvn package

[INFO] Building HR1[INFO] task-segment: [package][INFO] ---------------------------

[INFO] [jar:jar][INFO] Building jar: D:\projects\myprojects\odtugDemo\hr1\model\target\hr1-model-1.0-SNAPSHOT.jar[INFO] -------------------------------------------------------------------------

[INFO] [war:war][INFO] Building war: D:\projects\myprojects\odtugDemo\hr1\viewController\target\hr1-viewController-1.0-SNAPSHOT.war

[INFO] [ear:ear][INFO] Copying artifact[war:nl.amis.demo.odtug.hr1:hr1-viewController:1.0-SNAPSHOT] to[hr1-viewController-1.0-SNAPSHOT.war][INFO] Copying artifact[jar:log4j:log4j:1.2.12] to[log4j-1.2.12.jar][INFO] Copying artifact[jar:commons-logging:commons-logging:1.0.4] to[commons-logging-1.0.4.jar][INFO] Could not find manifest file: D:\projects\myprojects\odtugDemo\hr1\ear\src\main\application\META-INF\MANIFEST.MF - Generating one[INFO] Building jar: D:\projects\myprojects\odtugDemo\hr1\ear\target\hr1-ear-1.0-SNAPSHOT.ear[INFO] -------------------------------------------------------------------------

9may 31, 2007

mvn exec:exec -PlocalOC4J

[INFO] [exec:exec][[INFO] 07/06/01 17:21:22 Notification ==>Uploading file hr1.ear ...[INFO][INFO] 07/06/01 17:21:22 Notification ==>Application Deployer for hr1 STARTS.[INFO][INFO] 07/06/01 17:21:22 Notification ==>Copy the archive to :\server\oc4j_101310\j2ee\home\applications\hr1.ear[INFO][INFO] 07/06/01 17:21:22 Notification ==>Initialize C:\server\oc4j_101310\j2ee\home\applications\hr1.ear begins...

[INFO][INFO] 07/06/01 17:21:24 Notification ==>Initialize hr1-viewController-1.0-SNAPSHOT begins...[INFO][INFO] 07/06/01 17:21:24 Notification ==>Initialize hr1-viewController-1.0-SNAPSHOT ends...[INFO][INFO] 07/06/01 17:21:24 Notification ==>Started application : hr1[INFO][INFO] 07/06/01 17:21:24 Notification ==>Binding web application(s) to site default-web-site begins...[INFO][INFO] 07/06/01 17:21:24 Notification ==>Binding hr1-viewController-1.0-SNAPSHOT web-module for application hr1 to site default-web-site under context root /hr1[INFO][INFO] 07/06/01 17:21:31 Notification ==>Initializing Servlet: javax.faces.webapp.FacesServlet for web application hr1-viewController-1.0-SNAPSHOT[INFO][INFO] 07/06/01 17:21:31 Notification ==>Binding web application(s) to site default-web-site ends...[INFO][INFO] 07/06/01 17:21:31 Notification ==>Application Deployer for hr1 COMPLETES. Operation time: 8273 msecs

10may 31, 2007

mvn verify -PlocalOC4J

11may 31, 2007

mvn deploy

[INFO] [deploy:deploy][INFO] Retrieving previous build number from ATAMaven2SnapshotsRepoUploading: file:\\amis-test-aa\maven2snapshots/nl/amis/demo/odtug/hr1/hr1-model/1.0-SNAPSHOT/hr1-model-1.0-20070601.171522-4.jar50K uploaded[INFO] Retrieving previous metadata from ATAMaven2SnapshotsRepo

[INFO] Uploading repository metadata for: 'snapshot nl.amis.demo.odtug.hr1:hr1-model:1.0-SNAPSHOT'[INFO] -------------------------------------------------------------------------

12may 31, 2007

mvn site

13may 31, 2007

Build automation server

14may 31, 2007

Demo Summary

ADF Faces (10.1.3.1) applicationWithout JDeveloper :

Unittesting Make a build Deploy ear file to OC4J Perform integrationtests Share artifacts Share information

15may 31, 2007

Infrastructure

16may 31, 2007

Software Studio

17may 31, 2007

Software development

The development environment Source control Delivery environments Issue management Library management Build automation / continuous integration Reporting and documentation Communication

18may 31, 2007

19may 31, 2007

Maven

Convention over configuration

Project Object Model objects / things xml file

Build Lifecycle actions / goals

Dependency (library, artifact) Management

20may 31, 2007

POM example

<project> <modelVersion>4.0.0</modelVersion> <groupId>nl.amis.demo.odtug.hr1</groupId> <artifactId>hr1</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <modules> <module>model</module> <module>viewController</module> <module>ear</module> </modules> <name>HR1</name> <description>This application manages employees and general

company information.</description> <url>http://amis-test-aa:8800/hr1/faces/index.jspx</url> <organization> <name>AMIS Services</name> <url>http://www.amis.nl</url> </organization> <issueManagement> <system>Jira</system> <url>http://amis-test-aa:8081/browse/HRONE</url> </issueManagement>

21may 31, 2007

POM example

<scm> <connection>scm:svn:http://amis-test-aa/svn/myrepo/hr1/trunk/ </connection> <developerConnection> scm:svn:http://amis-test-aa/svn/myrepo/hr1/trunk/ </developerConnection> <url>http://amis-test-aa/svn/myrepo/hr1/trunk/</url> </scm> <developers> <developer> <id>aino.andriessen</id> <name>Aino Andriessen</name> <email>aino.andriessen@amis.nl</email> <organization>AMIS</organization> <roles><role>developer</role></roles> <timezone>+1</timezone> </developer> </developers> <distributionManagement> <repository> <id>AMISMaven2Repo</id> <url>file:\\amis-test-aa\maven2</url> </repository> </distributionManagement>

22may 31, 2007

Pom Example

<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation> src/main/resources/amis_checkstyle.xml </configLocation> </configuration> </plugin> </plugins> </reporting></project>

23may 31, 2007

Build Lifecycle

Organized sequence of phases like compile, test, package, build etc. The actual work is done by goals which are bound to a certain phase.

Configuration (if necessary) in pom

Other lifecycles clean site

validate

generate-sources

process-sources

generate-resources

process-resources

compile

process-classes

generate-test-sources

process-test-sources

generate-test-resources

process-test-resources

test-compile

test

prepare-package

package

pre-integration-test

integration-test

post-integration-test

verify

install

deploy

24may 31, 2007

Execution

mvn compile mvn compile:compile mvn compile:test-compile

mvn jar mvn jar:jar mvn jar:sign mvn test-jar:jar

25may 31, 2007

Dependency Management

Defined in the POMDownloaded from repository when neededStored in local repository

<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.oracle.adf</groupId> <artifactId>adfbinding</artifactId> <version>10.1.3.39.84</version> <scope>provided</scope> </dependency> <dependency> <groupId>nl.amis.demo.odtug.hr1</groupId> <artifactId>hr1-model</artifactId> <version>${project.version}</version> </dependency></dependencies>

26may 31, 2007

Maven repositories

27may 31, 2007

Maven repositories 2

Local InternalCentral

http://repo1.maven.org/maven2/

External Codehaus java.net ...

28may 31, 2007

Internal repository

commercial librariesnon-public librariescompany products

call mvn deploy:deploy-file -DgroupId=com.oracle.jdbc -DartifactId=ojdbc14 -Dversion=10.2.0.1 -Dfile=ojdbc14.jar -Dpackaging=jar -DrepositoryId=AMISMaven2Repository -Durl=%MAVEN_REPO_URL%

29may 31, 2007

Maven 'bits and pieces'

PluginsProjectsiteReportsProfilesSnapshotsReleaseArchetype ...

30may 31, 2007

ADF & JDeveloper & Maven

31may 31, 2007

Mavenize an ADF application

Dependency managementPOM filesTools

32may 31, 2007

Tools

admin_client.jar utilityojspc.jar utility [JDeveloper] [oc4j]

33may 31, 2007

JDeveloper library management

JDeveloper has a great library management system... as long as you stay in JDeveloper as long as you use the provided libraries

34may 31, 2007

JDeveloper library (mis)management - 2

Version management JDeveloper version

• What is the impact of service updates?

OC4J version ADF version

External libraries managementWhat if part of the application is developed in

another IDE?

35may 31, 2007

Library management

36may 31, 2007

Dependencies

Put (deploy) libraries in the internal repositoryKeep pom file(s) in sync

<dependencies> <dependency> <groupId>com.oracle.adf</groupId> <artifactId>adfshare</artifactId> <version>10.1.3.39.84</version> <scope>provided</scope> </dependency></dependencies>

37may 31, 2007

Required libraries

ADF• adfshare, adfui, adf-controller, adfbinding, adfm,

bc4jdomorcl, bc4jmt, bc4jct, bc4jdatum, bc4jhtml, datatags, graphtags, bc4jimdomains, ordim

JDeveloper • oc4j-internal, oc4j, adf-faces-impl, adf-faces-api, jdev-

cm, ojmisc, xmlparserv2, ojsp, ojsputil

call mvn deploy:deploy-file -DgroupId=com.oracle.adf -DartifactId=adfshare -Dversion=%ADF_VERSION% -Dfile=%JDEV_HOME%/BC4J/lib/adfshare.jar -Dpackaging=jar -DrepositoryId=%REPO_ID% -Durl=%REPO_URL%

38may 31, 2007

UnitTest ADF applications

BC4J JUnit extensionJDBC based AM configuration 'Basetest' per application module

Utility methods to create connection, handle jaas and provide easy access to view objects

Define (at least) a testcase per viewobject

protected HrServiceImpl getHrService () { return (HrServiceImpl) getApplicationModule(); }

39may 31, 2007

Integration tests

Start application serverPrepare the databaseDeploy applicationRun tests

front-end database application

Undeploy applicationStop application server

40may 31, 2007

Integration tests

Front-end Selenium

Back-end / Database QCTO utPLSQL

Tools dbunit Maven sql plugin Maven exec plugin (JDeveloper) ant tasks

41may 31, 2007

Deploy to OC4J

Command-lineoc4j admin_client.jar utility in ear project or associated with a certain

phase mvn exec:exec -PlocalOC4J

Unfortunately no Cargo plugin cargo:start, cargo:stop, cargo:deploy

Define local dependencies (location of admin_client.jar) in local settings.xml

42may 31, 2007

Example

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <execution> <id>deployApp</id> <phase>pre-integration-test</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>${java.home}/bin/java</executable> <arguments> <argument>-jar</argument> <argument>${oc4j.adminclient.home}\j2ee\home\admin_client.jar</argument> <argument>${ias.deploy.url}</argument> <argument>${ias.username}</argument> <argument>${ias.password}</argument> <argument>-deploy</argument> <argument>-file</argument> <argument>../ear/target/hr1-ear-${version}.ear</argument> <argument>-deploymentName</argument> <argument>hr1</argument> <argument>-bindAllWebApps</argument> </arguments> </configuration> </execution> </executions></plugin>

java -jar C:\server\oc4j_101310\j2ee\home\admin_client.jar deployer:oc4j:localhost oc4jadmin oc4jadmin -deploy -file hr1-ear-1.0-SNAPSHOT.ear -deploymentName hr1 -bindAllWebApps

43may 31, 2007

Project organisation

Directory layout default Maven layout

Multi module projects

44may 31, 2007

ADF Archetype

AMIS maven-archetype-adf :

mvn archetype:create

-DarchetypeGroupId=nl.amis.maven.archetypes

-DarchetypeArtifactId=maven-archetype-adf

-DarchetypeVersion=10.1.3.1-1

-DremoteRepositories=http://amis-test-aa/maven2

-DgroupId=nl.amis.demo.odtug

-DartifactId=hr1

45may 31, 2007

projectfile generation

Create jws and jpr filesmyFaces - Trinidad JDev plugin

Add to internal (or local) repository

Execute (AMIS / AXI version) :

http://technology.amis.nl/blog/?p=1279

mvn nl.amis.maven.plugins:maven-axi-jdev-plugin:10.1.3.0.4:jdev

46may 31, 2007

Issues

Regeneration is possible

Add pom manually to project propertiesProject and repo on same diskNo JHeadstart generation

but could be easily added

VersionNo official Maven plugin yet

47may 31, 2007

Running Maven from JDeveloper

Waiting for a JDeveloper extension ;-)Ant tasks

48may 31, 2007

Conclusion

Continuous integration is essential for the development process!

Using Maven, ADF Faces applications can be continuously integrated!

49may 31, 2007

aino.andriessen@amis.nl

http://technology.amis.nl/blog