Introduction
The Oracle Developer Cloud Service (DevCS) is a cloud-based software development Platform as a Service (PaaS) and a hosted environment for your application development infrastructure. It provides an open source standards-based solution to develop, collaborate on, and deploy applications within Oracle Cloud. Some of the core features offered by DevCS include a hosted GIT repository, a Maven repository, Issue Tracking capabilities, a Hudson Continuous Integration (CI) server, Wiki collaboration, code-review, roles and responsibilities separation, and many more. The complete list of features is available here.
While the documentation of all these features is available at http://docs.oracle.com/cloud/latest/devcs_common/index.html , in this blog we’ll concentrate on the Maven aspect of DevCS. Specifically, we’ll describe how one can :
- Populate the DevCS Maven Repository
- Use Maven to compile, package and deploy a java application to a Java Cloud Service-SaaS Extension (JCS-SX) instance
Developer Cloud Service lets you create a number of ‘projects’. With each project, an instance of Hudson CI Server, a GIT repository, a Maven Repository and a Wiki server are allotted. Below is a snapshot of the DevCS project home page:
The environment specific data has been redacted from the images in this blog.
It can be seen above that there are two git repositories attached to the project. DevCS allows a number of GIT repositories, both hosted and external, to be attached to a project. This provides flexibility to the Project Management team within your organization to logically separate projects as needed. The GIT Repositories can be managed via the Admin tab, where the result is shown below :
Populating the Maven Repository
In this section we will go through the steps to populate the DevCS Maven repository with the Weblogic 12.1.2 libraries, although the steps are valid for any version of Weblogic 12c.
Since the Weblogic libraries are Oracle copyrighted, care must be taken to ensure the libraries aren’t publicly accessible. Since a DevCS Maven repository is protected via HTTP Authentication, it’s OK to upload the libraries there.
The entire process can be divided into three main steps :
- a. Setting up Maven on a local machine.
- b. Installing Weblogic binaries on the local machine.
- c. Pushing the local binaries to the remote Maven repository.
Before starting the upload, it is important to consider the network latency and upload speed to ensure the upload happens as quickly as possible.
Also, if a large number of libraries are to be uploaded, it is worth considering a VNC type session, so that session interruptions do not interfere with the upload.
a) Setting up Maven on the local Machine
- i. Download and install the apache-maven-3.x.x (we used 3.0.5) on the local Machine (say a linux VM).
- ii. Open MVN_HOME/conf/settings.xml and make the following changes.
-
- 1) Under the ‘proxies’ section, specify the appropriate proxy, as given below:
-
<proxies> <proxy> <active>true</active> <protocol>http</protocol> <host>PROXY_URL</host> <port>80</port> <nonProxyHosts>www.anything.com|*.somewhere.com</nonProxyHosts> </proxy> </proxies>
- 2) Under the ‘servers’ section, specify a remote Maven server called remoteRepository. This will hold the username/password details when connecting to the ‘remoteRepository’, i.e. our DevCS Maven Repository :
-
<servers> <server> <id>remoteRepository</id> <username>USERNAME</username> <password>PASSWORD_IN_PLAINTEXT</password> </server> </servers>
-
The DevCS Maven Repository is protected, and only users who have access to the project can view the associated repository. The authentication mechanism is basic HTTP. The username/password above will be used for authentication before the upload.
- 3) Under the ‘profiles’ section, specify the default value of ‘remoteRepository’, as mentioned below:
-
<profiles> <profile> <id>default</id> <repositories> <repository> <id>remoteRepository</id> <name>Remote Weblogic Repository</name> <url>dav:https://developer.us2.oraclecloud.com/……/maven/</url> <layout>default</layout> </repository> </repositories> </profile> </profiles>
The ‘url’ above can be found on the DevCS home page, as seen in the above image. Also note the ‘dav:’ in the URL, signifying that the upload will use the WebDAV protocol.
- 4) Make sure the default profile is activated :
-
<activeProfiles> <activeProfile>default</activeProfile> </activeProfiles>
b) Installing Weblogic binaries on the local machine
- i. Download the Weblogic 12.1.2 ‘Zip distribution for Mac OSX, Windows, and Linux’ from Oracle Technology Downloads . We used the zip distribution only for demonstration purposes, any other type of installation would work as well.
- ii. Unzip the downloaded file to any location (eg: /home/myhome/mywls ).
- iii. Set JAVA_HOME and MW_HOME, eg :
- 1) $export JAVA_HOME=/home/myhome/myjavahome
- 2) $export MW_HOME=/home/myhome/mywls/wls12120
- iv. Run MW_HOME/configure.sh . This unpacks all the jar files
c) Pushing the local weblogic binaries to the remote maven repository
- i. On the local VM, ensure MVN_HOME/bin is available in the $PATH variable
- ii. ‘cd’ to location ‘/home/myhome/mywls/wls12120/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.2’
- iii. Create a file, pom.xml , with the following content :
-
<project> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.oracle</groupId> <artifactId>my-app</artifactId> <!--The version, groupId, artifactId above can be anything. --> <version>1</version> <build> <extensions> <extension> <artifactId>wagon-webdav-jackrabbit</artifactId> <groupId>org.apache.maven.wagon</groupId> <version>1.0-beta-7</version> </extension> </extensions> </build> </project>
The above pom.xml declares the wagon webdav plugin to be part of the mvn context. This library is used for uploading content to the remote repository using the WebDAV protocol.
- iv. Run the command :
-
mvn deploy:deploy-file -DpomFile=oracle-maven-sync.12.1.2.pom -Dfile=oracle-maven-sync.12.1.2.jar -DrepositoryId=remoteRepository -X -Durl=dav:https://developer.us2.oraclecloud.com/……/maven/
- This populates the local Maven repository, and deploys the file oracle-maven-sync.12.1.2.jar, its associated pom, and the MD5 and SHA1 hash of each to the remote repository specified by the -Durl parameter. The -DrepositoryId is used to pick up the authentication information from settings.xml (which we set above in Section a.2).
- v. Run the command :
-
mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=/home/myhome/mywls/wls12120 -Doracle-maven-sync.serverId=remoteRepository
- This command invokes the ‘Oracle Maven Synchronization Plugin’, specifically the coordinate com.oracle.maven:oracle-maven-sync:push , which uploads the local weblogic jars to the remote repository. This command recursively traverses through various dependencies and uploads them all. Depending on the network connection/upload speed, this may take a couple of hours.
- Please note that this command uses the pom.xml file defined in step#iii above.
Use Maven to compile, package and deploy a java application to JCS-SX
We assume that the source java project is checked into the DevCS GIT repository.
The following pom.xml can be used for compiling and packaging the project. It must also be checked into the GIT repository.
<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.oracle.samples</groupId> <artifactId>simpleJavaApplication</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>simpleJavaApplication</name> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>com.oracle.weblogic</groupId> <artifactId>weblogic-server-pom</artifactId> <version>12.1.2-0-0</version> <type>pom</type> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> <repositories> <repository> <id>remoteRepository</id> <url>https://developer.us2.oraclecloud.com/……/maven/</url> <layout>default</layout> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>remoteRepository</id> <url>https://developer.us2.oraclecloud.com/……/maven/</url> </pluginRepository> </pluginRepositories> </project>
The things to note are :
- The com.oracle.weblogic and junit dependencies
- Maven compiler plugin which lets us specify the -source and -target options while using javac (optional)
- Maven Repository url that specifies the location of the Weblogic libraries (i.e. the repository we just populated)
Below are the steps for setting up the Hudson build and deployment options on DevCS:
- a) On the DevCS project home page, click on the ‘Build’ tab, and create a new job
- 2) Name the new job. On the configurations page, set the following :
-
- a) JDK Version
- b) Git Repository details
- c) Create a Maven 3 Build Step and specify ‘clean package’ as the goals. Also ensure the pom.xml file is specified correctly.
- d) In the post-build step check the ‘Arhive the artifacts’ option, specifying the file(s) to be archived, as shown below . The archived file(s) will be used to deploy the generated artifacts to the associated JCS-SX instance.
-
- Save the job. Run it once to make sure the build executes successfully
- 3) Go to the ‘Deploy’ tab and create a new Deployment Configuration :
- The options in the image above are self-explanatory. The application ‘TestConfiguration’ is to be deployed to the JCS-SX instance ‘jcssx02′. The artifacts generated from the specific Hudson job and build number are deployed to the ‘jcssx02′ instance. One can also schedule an Automatic deployment (as compared to ‘On Demand’) on every successful Hudson build.
Conclusion
We’ve demonstrated how to use the Developer Cloud Service to automate your Maven based development lifecycle. We saw how the Maven Repository can be populated with weblogic or other custom jars, and how the Hudson build jobs and deployments can be configured.
We’d be remiss if we didn’t mention the newly introduced Oracle Maven Repository . Steve Button explains it nicely in his blog https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle . Efforts are underway to make the Oracle Maven Repository work with DevCS. More on that when we have more information.
All content listed on this page is the property of Oracle Corp. Redistribution not allowed without written permission