"Unknown packaging: eclipse-plugin" in Maven - 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.

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.

Deploy Two Wars to a Repository with One Pom

I have a single project that builds two war files. The only difference between the two are configuration files and the war name. I'm trying to deploy the wars to our Nexus repository for distribution management. I know how to name the wars differently in the pom by using:
<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>
<artifactId>example</artifactId>
<version>1.1.2</version>
<packaging>war</packaging>
<properties>
<buildVersion>counter</buildVersion>
</properties>
<build>
<finalName>example_${buildVersion}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>nexus.example</id>
<url>https://example.com/nexus/content/repositories/wars</url>
</repository>
</distributionManagement></project>
But, when I run mvn deploy, the name of the war that is deployed doesn't have the buildVersion so both wars are named the same.
I've found the deploy:deploy-file directive, but it needs the version of the war that's being deployed defined as a -D spec. Since I'm doing CD, I don't have the version on the command line within Bamboo.
Has anyone come across this situation before and what was done to accomplish it?

Jenkins and 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>

adding java core libraries from maven central repository

I am new to maven.
I was trying a simple maven project in which i want to include the core java library from maven central repository.
I found this dependency from search.maven.org
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun</groupId>
<artifactId>rt</artifactId>
<version>1.5.0_06</version>
<name>Sun Java Runtime Environment</name>
<description>Java Runtime Environment that can be found in Sun's JRE lib folder</description>
But maven stores rt's pom in local repository, i am not able to access rt jar which has java core libraries.
I suggest following :
# Create maven project using Eclipse
# Open pom.xml and add following build tag
Refer below sample 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>
<groupId>com.ays</groupId>
<artifactId>java-solution</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<!-- Added Java8 support -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
# Right click on Project and choose Maven-> Update Project...
# Refresh your project you will see JRE System Library [JavaSE-1.8]
# Hope this will helps!!

Maven descriptor (META-INF/maven) duplicate entry in archive

I'm facing a problem with maven build. I have several ejb projects. After maven build the jar-file contains the maven descriptor in META-INF/maven twice, i.e. if I extract files to disk 7zip asks to overwrite files although extracted to a new folder. If a specify <addMavenDescriptor>false</addMavenDescriptor> in the archive-tag of the ejb plugin then the maven decriptor is still generated but only once. Is there another place where I can disable maven descriptor generation or does anybody know the reason for the duplicate generation?
Maven version is: 3.0.3
Project structure is like:
-pom
-ejb
Here is the pom.xml of the EJB module:
<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>
<artifactId>TestMavenDescriptors</artifactId>
<groupId>de.test</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>TestEJB</artifactId>
<packaging>ejb</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>
<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>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Here is the pom.xml of the parent project.
<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>de.test</groupId>
<artifactId>TestMavenDescriptors</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>TestEJB</module>
</modules>
</project>
I found out that this is a problem special to eclipse version (I have RAD 8 trial) and possibily of the m2e plugin version. The above behavior (duplicate generation of maven descriptors) occurs only if I have the EJB project in my workspace added. That means if I remove the EJB project from workspace (without deleting contents on disk) such that only the hierarchal parent maven project (pom packaged) is existing in the workspace (which contains the EJB project but EJB project is then not known to eclipse) then everything works fine. Strange, isn't it?!
BTW: on current eclipse (java ee package) this doesn't occur, all fine there.

Resources