Jenkins and Maven - maven

see Project Structure I am trying to deploy my SOA project using Jenkins and Maven.
while deployment I am getting below error. Can some one please help me with this.
while using only maven command I am able to deploy this project on SOA server. I am getting error only when I try to deploy project using Jenkins.
Started by user Atul Gupta
Building in workspace C:\Users\atulgupt\.jenkins\workspace\sca-test
Checking out a fresh workspace because there's no workspace at C:\Users\---\.jenkins\workspace\sca-test
Cleaning local Directory .
Checking out ----/BPEL/Trunk/test-soa-application at revision '2016-09-14T15:34:08.345 +0530'
Parsing POMs
**Failed to transfer Could not find artifact com.oracle.soa:sar-common:pom:12.2.1-0-0 in central (http://repo.maven.apache.org/maven2)
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException**: **Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Could not find artifact com.oracle.soa:sar-common:pom:12.2.1-0-0 in central (http://repo.maven.apache.org/maven2) and** 'parent.relativePath' points at no local POM # line 21, column 13
Parent POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.my.test</groupId>
<artifactId>test-soa-application</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<!-- Add project modules -->
<module>test-soa-project</module>
</modules>
</project>
Project POM.xml:-
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.my.test</groupId>
<artifactId>test-soa-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sar</packaging>
<!--
This POM was generated from the SOA Maven Archetype.
Comments in this POM guide you how to use it with your project.
This POM relates to this SOA Composite, i.e. the one in this same directory.
There is another POM in the SOA Application directory (up one) which handles
the whold SOA Application, which may contain additional projects.
The parent points to the common SOA parent POM. That is a special POM that is
shipped by Oracle as a point of customization (only). You can add default values
for properties like serverUrl, etc. to the SOA common parent POM, so that you
do not have to specify them over and over in every project POM.
-->
<parent>
<groupId>com.oracle.soa</groupId>
<artifactId>sar-common</artifactId>
<version>12.2.1-0-0</version>
<relativePath></relativePath>
</parent>
<properties>
<!-- these parameters are used by the compile goal -->
<scac.input.dir>${project.basedir}/SOA/</scac.input.dir>
<scac.output.dir>${project.basedir}/target</scac.output.dir>
<scac.input>${scac.input.dir}/composite.xml</scac.input>
<scac.output>${scac.output.dir}/out.xml</scac.output>
<scac.error>${scac.output.dir}/error.txt</scac.error>
<scac.displayLevel>1</scac.displayLevel>
<!-- if you are using a config plan, uncomment the following line and update to point
to your config plan -->
<!--<configplan>${scac.input.dir}/configplan.xml</configplan>-->
<!-- these parameters are used by the deploy and undeploy goals -->
<composite.name>${project.artifactId}</composite.name>
<composite.revision>${project.version}</composite.revision>
<composite.partition>default</composite.partition>
<serverUrl>http://localhost:7071</serverUrl>
<user>atulgupt</user>
<password>july#2016</password>
<overwrite>true</overwrite>
<forceDefault>true</forceDefault>
<regenerateRulebase>false</regenerateRulebase>
<keepInstancesOnRedeploy>false</keepInstancesOnRedeploy>
<!-- these parameters are used by the test goal -->
<!-- if you are using the sca-test (test) goal, you need to uncomment the following
line and point it to your jndi.properties file. -->
<!--<jndi.properties.input>${basedir}/jndi.properties</jndi.properties.input>-->
<scatest.result>${scac.output.dir}/testResult</scatest.result>
<!-- input is the name of the composite to run test suties against -->
<input>test-soa-project</input>
<oracleHome>
${env.ORACLE_HOME}
</oracleHome>
</properties>
<!--
These refer to the properties defined above. You should probably not need to make
any changes beflow this point - these just point to the properties above.
-->
<build>
<plugins>
<plugin>
<groupId>com.oracle.soa.plugin</groupId>
<artifactId>oracle-soa-plugin</artifactId>
<version>12.2.1-0-0</version>
<configuration>
<compositeName>test-soa-project</compositeName>
<composite>${scac.input}</composite>
<sarLocation>${scac.output.dir}/sca_${project.artifactId}_rev${version}.jar</sarLocation>
<serverUrl>${serverUrl}</serverUrl>
<!-- note: compositeRevision is needed to package, revision is needed to undeploy -->
<compositeRevision>${composite.revision}</compositeRevision>
<revision>${composite.revision}</revision>
<scacInputDir>${scac.input.dir}</scacInputDir>
<!-- Uncomment the appHome property if your composite
depends on MDS. -->
<!--<appHome>${project.basedir}/..</appHome>-->
<!-- If you have a composite which contains a component that
depends on MDS (eg. Human Task, Business Rule) AND you
want to use a file-based MDS repository, then you
need to do either:
1. update the .adf/META-INF/adf-config.xml to point to
the correct location of the file based repository, i.e.
remove the reference to ${soa.oracle.home} in that file, or
2. define oracleHome and soaOracleHome here and leave the adf-config.xml file
as is. Note that the correct value for soaOracleHome is the path to
your SOA Quickstart or JDeveloper install directory,
with "/soa" appended to it.
-->
<!--<oracleHome>JDEV_HOME</oracleHome>-->
<!--<soaOracleHome>JDEV_HOME/soa</soaOracleHome>-->
<input>${input}</input>
</configuration>
<!-- extensions=true is needed to use the custom sar packaging type -->
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>com.oracle.adf.plugin</groupId>
<artifactId>ojdeploy</artifactId>
<version>12.2.1-0-0</version>
<configuration>
<ojdeploy>
${oracleHome}/jdeveloper/jdev/bin/ojdeploy.exe
</ojdeploy>
<workspace>
${basedir}/../test-soa-application.jws
</workspace>
<project>
test-soa-project
</project>
<profile>
test-soa-project
</profile>
<outputfile>
${project.build.directory}/${project.build.finalName}.jar
</outputfile>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Related

OpenLiberty Maven Plugin

I am trying to create a runnale openliberty server as part of my release process. I have a a multi module maven project with a submodule dedicated to packaging the server as a runnable. When I do a mvn clean package a lovely executable jar is produced which bundles one of the other submodules (war). The problem I am facing is when I do a maven deploy to our asset repo the packaged server is being uploaded as a zip file rather than a jar file. Does anyone know how to get the deploy plugin to upload the jar?
Here is a sample pom file
<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>
<parent>
<groupId>au.com.xxxx.xxxx</groupId>
<artifactId>xxx-backend-parent</artifactId>
<version>0.0.16-SNAPSHOT</version>
</parent>
<artifactId>xxxx-openliberty-server</artifactId>
<packaging>liberty-assembly</packaging>
<name>fusion-openliberty-server</name>
<description>Runnable Jar containing xxxxand the OpenLiberty applictaion server</description>
<dependencies>
<!-- Package xxxx-application.war with server assembly -->
<dependency>
<groupId>au.com.xxx.xxx</groupId>
<artifactId>xxxx-application</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Enable liberty-maven-plugin -->
<plugin>
<groupId>net.wasdev.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>2.6.1</version>
<extensions>true</extensions>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-javaee8</artifactId>
<version>18.0.0.3</version>
<type>zip</type>
</assemblyArtifact>
<include>runnable</include>
<serverName>xxx</serverName>
<appsDirectory>apps</appsDirectory>
<serverEnv>${basedir}/src/main/resources/server.env</serverEnv>
<configFile>${basedir}/src/main/resources/server.xml</configFile>
<jvmOptionsFile>${basedir}/src/main/resources/jvm.options</jvmOptionsFile>
<bootstrapProperties>
<app.context.root>xxx-app</app.context.root>
<default.http.port>5000</default.http.port>
<default.https.port>5443</default.https.port>
</bootstrapProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>
I don't have an answer to your question but an explanation why this happens. Every packaging type (jar, war, liberty-assembly) defines a fixed extension for the artifact(s) it creates. The liberty-assembly types defines zip as it extension. This extension is used by the maven-install-plugin and maven-deploy-plugin regardless how the local file is names. I did quite some code digging but couldn't find a way to change this. It's probably sth. that only liberty-maven-plugin can change/fix.

Retrieve all jars from Local jfrog Repository using Maven

I am hosting a Local Repository with 80+ Jar files which are related to our internal Project
Something like this
I want to add a tag in my Maven pom.xml where in I retrieve all the jar files in one shot when I create a new project in Eclipse.
These jars are static and will not change.
Can anyone please help in setting up this?
In Artifactory - "Set me Up", I can see this TAG, but its for pushing a final jar
You have at least two options:
1. Use a parent pom
Add all the 80 dependencies to a POM which looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<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>your.company</groupId>
<artifactId>ourDependencies</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging> <!-- IMPORTANT -->
<dependencies>
<!-- place here 80 dependencies -->
<dependency>
...
</dependency>
</dependencies>
<build> <!-- optional -->
<plugins>
<plugin>
...
</plugin>
</plugins>
</build>
<distributionManagement>
... <!-- optional -->
</distributionManagement>
</project>
In the project that needs the dependencies, add a <parent> element to the pom.xml:
<project>
<groupId>your.company</groupId>
<artifactId>newApplication</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging> <!-- or war or ... -->
....
<parent>
<groupId>your.company</groupId>
<artifactId>ourDependencies</artifactId>
<version>1.0.0</version>
</parent>
...
</project>
Keep in mind that every project can have only one parent.
2. Create an archetype
This way is more complex. You can create a simple project similar to "HelloWorld" which contains all the dependencies. Based on this project, you can create an archetype which serves as a template when you create a new Maven project.
More Informations:
Introduction to archetypes
archetype tutorial

Retaining module keys when migrating Sonar from Maven runner to Ant runner

We'd like to convert our existing multi-module Sonar projects that use the Maven runner to use the Ant runner instead. These projects all use Ant for their main build anyway, and it will be a lot more convenient to have everything done with Ant.
We must preserve the history of the projects, meaning that we need to retain the keys used for the projects and their modules. I'm having trouble doing that.
Our current Maven parent pom looks something like this (the ui is similar, though the language is Flex):
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>anapp</artifactId>
<name>An Application</name>
<version>7.0</version>
<packaging>pom</packaging>
<modules>
<module>server</module>
<module>ui</module>
</modules>
<properties>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
</properties>
</project>
The server module pom looks like this:
<project ...>
<parent>
<groupId>com.example</groupId>
<artifactId>anapp</artifactId>
<version>7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>anapp_server</artifactId>
<name>Server</name>
<version>7.0</version>
<build>
<outputDirectory>build/classes</outputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<testOutputDirectory>build/test/classes</testOutputDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<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>
<properties>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
<sonar.emma.reportPath>build\codecoverage-results</sonar.emma.reportPath>
<sonar.surefire.reportsPath>build\test\results</sonar.surefire.reportsPath>
</properties>
</project>
We set the sonar.branch property on the command line to "R7".
The key of the "myapp" project looks like
com.example:anapp:R7
The key of the "Server" module within the "myapp" project looks like this:
com.example:anapp_server:R7
For the same project to use the Ant task, I set up the properties as:
sonar.dynamicAnalysis=reuseReports
sonar.modules=server,ui
sonar.projectBaseDir=...
sonar.projectKey=com.example\:myapp
sonar.projectName=An Application
sonar.projectVersion=7.0
server.sonar.binaries=...
server.sonar.dynamicAnalysis=reuseReports
server.sonar.emma.reportPath=...
server.sonar.java.coveragePlugin=emma
server.sonar.java.source=1.6
server.sonar.language=java
server.sonar.libraries=...
server.sonar.projectBaseDir=...
server.sonar.projectKey=com.example\:anapp_server
server.sonar.projectName=Server
server.sonar.sources=...
server.sonar.surefire.reportsPath=...
server.sonar.tests=...
ui.sonar.dynamicAnalysis=false
ui.sonar.language=flex
ui.sonar.projectBaseDir=...
ui.sonar.projectKey=com.example\:anapp_ui
ui.sonar.projectName=UI
ui.sonar.sources=...
The key of the project looks the same as with the pom file ("com.example:anapp:R7"); however, the server module key looks like
com.example:anapp:com.example:anapp_server:R7
This difference will cause us to lose the history of the modules if I publish using them.
Is there a way for me to specify the Ant properties to generate the same key as with our existing Maven pom files?
Our Sonar admin tells me he can manually change the keys for us, but this would be tedious and time consuming. We'll resort to that if we have to, but I'm hoping I'm just missing something obvious that would save us a lot of work.
There's no way to transform Maven-style keys in standard SonarQube-style keys.
So your admin is right, the only way to do it is to manually update the keys through the interface, as explained on the documentation.

"Unknown packaging: eclipse-plugin" in Maven

I want to build a project in Maven using eclipse-plugin packaging, but I get the following error for my POM:
[ERROR] Unknown packaging: eclipse-plugin # line 15, column 13 .
pom.xml:
<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>
<parent>
<relativePath>../releng/pom.xml</relativePath>
<groupId>net.sf.logsaw</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>net.sf.logsaw.core</artifactId>
<version>1.0.4-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>LogSaw Core Plugin</name>
</project>
The packaging type eclipse-plugin is defined by a Maven build extension called Tycho. In order to use Tycho's packaging types, you need to configure Tycho as a build extension:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
Also, Tycho requires additional metadata files to be present, e.g. an OSGi manifest for eclipse-plugin modules. Another major difference of a Tycho project compared to a regular Maven project is that you have to configure the so-called target platform, e.g. by defining a repository with layout=p2, in case your project references any external artifacts. To get started, you may have a look at this example project.
For more information, you can also check out Tycho's documentation wiki, e.g. the reference card page.

creating war file using maven-ear-plugin and defining it in one pom.xml

I am at the starter level of the maven usage. I hope I can explain my problem clearly, I want to create an ear file which contains war file inside it. And I planned to use to create a war file from the start. Also I want to do it in my pom.xml at my project and there is only one pom.xml, here is the problem;
Can I create ear file and which contains this war that I created at the same time in one pom.xml file?
when I try to create war file in webmodule tag, here is the problem that I encounter " Artifact[war:denem.denem:denem] is not a dependency of the project." I understood so that's why I added dependency for this file in the same pom.xml but this time I encountered that problem
(By the way my command to build this pom is "mvn clean package" )
"1 required artifact is missing.
for artifact:
com.denem.denem:com.denem.de2:ear:v0.1"
It tries to find this war file but I want to create it not to find it. Here the code in my pom.xml file;
<parent>
<groupId>denem.denem</groupId>
<artifactId>com.denem.denem</artifactId>
<version>v0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>denem.denem</groupId>
<artifactId>com.denem.de2</artifactId>
<version>v0.1</version>
<packaging>ear</packaging>
<properties>
<cxf.version>2.2.5</cxf.version>
</properties>
<dependencies>
<dependency>
<groupId>denem.denem</groupId>
<artifactId>denem</artifactId>
<version>v0.1</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.5</version>
<configuration>
<finalName>edu</finalName>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>denem.denem</groupId>
<artifactId>denem</artifactId>
<contextRoot>/WebContent</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
I guess I am doing lots of things wrong. But If you can help me I will be glad. Thank you anyway.
You need to create a modular project.
Create:
a parent project of type "pom";
a child project of type "war";
if needed, child projects of type "ejb";
if needed, child projects of type "jar" (common libraries);
one project of type "ear", that has all of the above as dependencies.
In the latter you need to configure the ear plugin putting all the modules that you need.

Resources