adding java core libraries from maven central repository - maven

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!!

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.

POM 'org.apache.maven.plugins:maven-clean-plugin' not found in repository

When I try to build/clean/install with maven I get the error below. Maven 2 worked but didn't download a package into the .m2/repository/ so I tried uninstalling maven 2 (sudo apt-get remove maven2) and reinstalling (sudo apt-get install maven2), setting the local repository to a map of my choosing in settings.xml of the maven map but I must've done something wrong. Anyone that can help me out?
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.apache.maven.plugins:maven-clean-plugin
Reason: POM 'org.apache.maven.plugins:maven-clean-plugin' not found in repository: Unable to download the artifact from any repository
org.apache.maven.plugins:maven-clean-plugin:pom:2.3
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.apache.maven.plugins:maven-clean-plugin
This is my 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>be.ugent.sop.p404</groupId>
<artifactId>P404</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>P404</name>
<build>
<plugins>
<!-- Set to compile using JDK 7 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- Avoid war plugin complaining missing web.xml -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>P404WAR</module>
<module>P404EJB</module>
<module>P404EAR</module>
</modules>
</project>
First check if maven is working or not after reinstalling
If it is working, there is chance that u downlaod a particular jar which needs credentials or proxy settings. Either define it in settings.xml or in pom.
remove all ur .m2 folder's repository and place settings.xml if neccessary
Its better if you share your pom.xml

How to Build Xcode build with Maven plugin

I'm trying to build Xcode app with maven plugin, i worte pom.xml as shown in below
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yqlabsEnterprise.SampleMaven</groupId>
<artifactId>SampleMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>xcode-lib</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>com.sap.prd.mobile.ios.mios</groupId>
<artifactId>xcode-maven-plugin</artifactId>
<version>1.14.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
i installed maven, and run with maven using terminal, but my app not build successfully, i got error
"Failed to execute goal com.sap.prd.mobile.ios.mios:xcode-maven-plugin:1.14.0:prepare-xcode-build (default-prepare-xcode-build) on project SampleMaven: Execution default-prepare-xcode-build of goal com.sap.prd.mobile.ios.mios:xcode-maven-plugin:1.14.0:prepare-xcode-build failed: A required class was missing while executing com.sap.prd.mobile.ios.mios:xcode-maven-plugin:1.14.0:prepare-xcode-build: Lorg/sonatype/aether/RepositorySystem"
will you please help me to solve this issue.
You'll need to downgrade to Maven 3.0.x since the plugin is not compatible with later versions of Maven. The reason is that the Java package org.sonatype.aether.* has been renamed to org.eclipse.aether.*.

"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.

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