S313467 - ADF BUILD PROCESS WITH MAVEN AND HUDSON Aino Andriessen Thursday, September 23, 11:00 | Hotel Nikko, Peninsula
S313467 - ADF BUILD PROCESS WITH
MAVEN AND HUDSON
Aino Andriessen
Thursday, September 23, 11:00 | Hotel Nikko, Peninsula
AMIS
Systems integrator
Co-sourcing
Maintenance
Oracle, Java, Open Source, ADF, DBA, SOA
AMIS technology school
APS
http://www.amis.nl
http://technology.amis.nl/blog/
AINO ANDRIESSEN
Technical Consultant
Technical Architect
Java, ADF, PL/SQL, XML, ...
SOA , Integration
Software engineering
Quality management
Agile development
http://www.fttech.net
S313467 - ADF BUILD PROCESS WITH
MAVEN AND HUDSON
Aino Andriessen
Thursday, September 23, 11:00 | Hotel Nikko, Peninsula
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.
WHY AUTOMATE
• Predictable
• Transparent
• Faster
• Less mistakes
• Fun
• Everybody's party
• Trackable
• Reporting
WHY NOT AUTOMATE
Too complex
Didn't know you could
do that
Take too much time to organize
Functionality is more
important
It's not my competence
How?
It can't be done
WHAT TO AUTOMATE
• Code generation
• Create a build
• Perform (unit)tests
• Deploy
• Release
• Code analysis
• Generate documentation
• Update incident information
• Notifications
• Reporting
• ...
DEMO
DEMO SUMMARY
• ADF Faces application that integrates a standalone taskflow
• Without JDeveloper
– Unittesting
– Make deliverables
– Deploy to WLS
– Code analysis
– Reporting
– Release
– Share artifacts
• Execution
– command line
– Hudson
– IDE's, (JDeveloper),
Delivery environmentsLibrary
Developer2Developer
2
Custom
Production
Developer2Developer
Source control
CorporateLibrary
Build automation
Test
Documentationsite
Development
Issue management
Tests
Inspection
Public Library
Reports
Documentation
Issue reports
Acceptance
Integration
'SCRIPTING'
• Maven
• ant
• make
• shell scripts
• sql scripts
• wlst
• ...
MAVEN OVERVIEW
• Convention over configuration
• Project Object Model
– objects / things / project content
– xml file
• Build Lifecycle
– actions / goals
• Dependency (library, artifact) Management
POM 1
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>nl.amis.demo.ae</groupId>
<artifactId>ae</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Demo ADF Maven applicatie</name>
<packaging>pom</packaging>
<modules>
<module>Model</module>
<module>ViewController</module>
<module>ear</module>
</modules>
<description>This application contains a simple HR application that includes a standalone taskflow.</description>
<url>http://192.168.149.1:7101/ea/faces/index.jspx</url>
<organization>
<name>AMIS Services</name>
<url>http://www.amis.nl</url>
</organization>
<issueManagement>
<system>Jira</system>
<url>http://xp-vm:8300/browse/DEMO</url>
</issueManagement>
POM 2
<developers><developer>
<id>aino.andriessen</id><name>Aino Andriessen</name><email>[email protected]</email><organization>AMIS</organization>
<roles><role>developer</role></roles><timezone>+1</timezone>
</developer>
</developers><scm><connection>scm:svn:http://xp-vm/svn/demos/referenceApps/trunk/exampleADFApplication/</connection><developerConnection>scm:svn:http://xp-vm/svn/demos/referenceApps/trunk/exampleADFApplication/</developerConnection><url>http://xp-vm/svn/demos/referenceApps/trunk/exampleADFApplication/</url>
</scm><distributionManagement><repository>
<id>xp-vm-releases</id><name>Internal Releases</name><url>http://xp-vm:8081/nexus/content/repositories/releases/</url>
</repository><snapshotRepository>
<id>xp-vm-snapshots</id>
<name>Internal Snapshots</name><url>http://xp-vm:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository><site>
<id>xp-vm-projectsites</id><name>Internal Projectsite</name><url>file:/data/projectsites/DemoAdfApp</url>
</site>
</distributionManagement>
BUILD LIFECYCLE
• Organized sequence of phases like compile, test,
package, build etc.
– Each goal (task) is implemented in a plugin.
– A goal is normally bound to a to a certain phase
• Configuration (if necessary) in pom
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
EXECUTION
• mvn compile
– mvn compile:compile
– mvn compile:test-compile
• mvn package
• mvn jar
– mvn jar:jar
– mvn jar:sign
– mvn test-jar:jar
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<packaging>jar</packaging>
DEPENDENCY MANAGEMENT
• Defined in the POM
• Downloaded from repository when needed
• Stored 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.model</groupId>
<artifactId>adfm</artifactId>
<version>${adfVersion}</version>
</dependency>
<dependency>
<groupId>nl.amis.demo.ae</groupId>
<artifactId>ae-stf-adflib</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
MAVEN REPOSITORIES
INTERNAL REPOSITORY
• third-party libraries
• company products
– releases
MAVEN 'BITS AND PIECES'
• Plugins
• Projectsite
• Reports
• Profiles
• Snapshots
• Release
• Archetype
• ...
ADF & JDEVELOPER & MAVEN
MAVENIZE AN ADF APPLICATION
• Dependency / library management
• POM files
• [Tools]
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
• JDeveloper hides the jar hell.
– Presents multiple jars as one library
JDEVELOPER LIBRARY (MIS)MANAGEMENT
• External libraries management
– user, project, system library; import as jar or as library
– location
• Version hiding
– ADF, JDeveloper, OC4J / WLS, ...
• jpr config
– location is relative to project
CHALLENGE
• Identify required jars
• Store them in the internal repository
• Define dependencies in pom
• Keep the pom file in sync with the JDev project libraries
JDEVELOPER LIBRARIES
REQUIRED JARS
• ADF
– 10g:
• adfshare, adfui, adf-controller, adfbinding, adfm, bc4jdomorcl,
bc4jmt, bc4jct, bc4jdatum, bc4jhtml, datatags, graphtags,
bc4jimdomains,ordim, ...
– 11g:
• adf-controller.jar, adf-controller-api.jar, adf-controller-rt-
common.jar, adfbcsvc.jar, adflibfilter.jar, mds, ...
• JDeveloper
• Weblogic
• Javax
• Glassfish
JDEV LIBRARY MANAGEMENT
• Deploy jars in the internal repository
• Define: groupId, artifactId, version
• Use scripts for reuse
mvn deploy:deploy-file
-DgroupId=com.oracle.adf.controller
-DartifactId=adf-controller
-Dfile=%MIDDLEWARE_HOME%\oracle_common\modules\
oracle.adf.controller_11.1.1\adf-controller.jar
-Dversion=%ADF_VERSION%
-Dpackaging=jar
-DrepositoryId=%REPO_ID%
-Durl=%REPO_URL%
• Create a pom per JDev library that contains all its jars.
• These poms can be (re)used as a single dependency in
project poms
JDEV LIBRARY MANAGEMENT
• Bundle jars per (JDev) library in an aggregate pom (bom)
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>nl.amis.adc.maven.libs.jdev</groupId>
<artifactId>adf-controller-runtime-lib</artifactId>
<version>11.1.1.3.0</version>
<packaging>pom</packaging>
<name>ADF controller Runtime library</name>
<properties>
<adfVersion>11.1.1.3.37.56.60</adfVersion>
</properties>
<dependencies>
<dependency>
<groupId>com.oracle.adf.controller</groupId>
<artifactId>adf-controller</artifactId>
<version>${adfVersion}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.oracle.adf.controller</groupId>
<artifactId>adf-controller-api</artifactId>
<version>${adfVersion}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.oracle.adf.controller</groupId>
<artifactId>adf-controller-rt-common</artifactId>
<version>${adfVersion}</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
JDEV LIBRARY MANAGEMENT
• Use aggregated pom as dependency in project pom
<dependency>
<groupId>nl.amis.adc.maven.libs.jdev</groupId>
<artifactId>adf-controller-runtime-lib</artifactId>
<version>${jdevLibrariesVersion}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
DEPLOY TO WLS
• wlst
• ant
• ojdeploy
• org.codehaus.mojo:weblogic-maven-plugin
– mvn weblogic:deploy -Plocal [-Dversion=1.0]
– mvn weblogic:start
– dependencies on weblogic libraries• wlfullclient.jar (wljarbuilder)
• weblogic.jar
• webservices.jar
• javax.enterprise.deploy_1.2.jar
• ...
• com.oracle.weblogic:weblogic-maven-plugin
EXAMPLE
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<adminServerHostName>${wls.admin.server}</adminServerHostName>
<adminServerPort>${wls.admin.port}</adminServerPort>
<adminServerProtocol>t3</adminServerProtocol>
<userId>${wls.admin.user}</userId>
<password>${wls.admin.password}</password>
<remote>true</remote>
<verbose>true</verbose>
<debug>true</debug>
<stage>false</stage>
<artifactPath>${ear.filename}</artifactPath>
<targetNames>${wls.target}</targetNames>
<name>${applicationName}</name>
<upload>true</upload>
<noExit>true</noExit>
<projectPackaging>ear</projectPackaging>
</configuration>
<dependencies>
<dependency>
<groupId>nl.amis.adc.maven.libs.jdev</groupId>
<artifactId>weblogic-lib</artifactId>
<version>${jdevDependenciesVersion}</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
DEPLOY TO OC4J
• Command-line
• oc4j admin_client.jar utility
– deploy to repository and use dependency plugin for run-time download
• no local dependencies
• in separate project
– mvn exec:exec -PlocalOC4J [-Dversion=1.0]
PROJECT ORGANISATION
• Directory layout
– default Maven layout
– JDev project config
• Multi module projects
CONFIG - MODEL
• Sources
• Extra Resources
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.jpx</include>
<include>**/*.xcfg</include>
</includes>
</resource>
maven-antrun-plugin
<copy file="../.adf/META-INF/connections.xml"
todir="${project.build.testOutputDirectory}/META-INF" />
<copy file="../.adf/META-INF/adf-config.xml"
todir="${project.build.testOutputDirectory}/META-INF" />
<copy file="../src/META-INF/jps-config.xml" todir="${basedir}/config" />
<copy file="../src/META-INF/cwallet.sso" todir="${basedir}/config" />
CONFIG - STANDALONE TASKFLOW
• Sources
• Packaging: jar
• Custom jar organization
• Extra Resources
– Generated at JDev deployment
• adflibWEBINDEX.txt
• oracle.adf.common.services.ResourceService.sva
• task-flow-registry.xml
<resource>
<directory>src/main/adfmsrc</directory>
<includes>
<include>**/*.cpx</include>
<include>**/*.dcx</include>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/webapp</directory>
...
USING MAVEN FROM JDEVELOPER
• External tools
• Ant task as wrappers
• Preview JDeveloper extension
• Code templates
HUDSON IS GREAT
HUDSON
• Multiple jobs per Application / Project
– clean install
– deployment
– QA
– documentation
– ...
• Organize them per view
• Use plugins
– release
– sonar
– ...
• Use Sonar
• ...
CONCLUSION
• Build automation is essential for the development process!
• Using Maven, ADF Faces applications can be succesfully
automated!