Maven could not resolve dependency of WebSphere provided dependency - maven

I am trying to import a legacy application on IntelliJ and most of the modules have dependencies to com.ibm.tools.target.was and com.ibm.tools.target.portal artifacts.
I am getting this in the Maven window of IntelliJ:
This is the error message I am getting on mvn install:
Failed to execute goal on project xxx-managers: Could not resolve dependencies for project com.xxx.xxx.xxx-managers:xxx-managers:ejb:0.0.1-SNAPSHOT: Failure to find com.ibm.tools.target:was:pom:8.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
I tried to imitate a similar procedure found in the IBM web knowledge center (https://www.ibm.com/support/knowledgecenter/en/SSHR6W/com.ibm.websphere.wdt.doc/topics/install_server_apis.html) but it did not work.
I added the was_public.pom as maven project and imported the project as a dependency to my other module.
I also tried to add WebSphere as a library dependency:
Nothing worked.
Please help, thanks in advance.
EDIT: This is my settings.xml (I copied it from an other environment in which the application is working) and it includes IBM repositories:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>ibm-maven-repo</id>
<name>ibm-maven-repo</name>
<url>http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>ibm-maven-repo</id>
<name>ibm-maven-repo</name>
<url>http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/</url>
</pluginRepository>
</pluginRepositories>
<id>standard-extra-repos</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>standard-extra-repos</activeProfile>
</activeProfiles>
</settings>

You miss some artifacts, e.g. com.ibm.tools.target:was:pom:8.0.0, and you need to either specify a repository in your settings.xml, where it should come from or install these artifacts into your local repository.

Related

Overriding central works in profile, but not directly?

I've spend a lot of time looking for error in maven configuration.
I've overriden central with internal caching repository:
<activeProfiles>
<activeProfile>internal</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>internal</id>
<repositories>
<repository>
<id>central</id>
<url>https://internal.rep/nexus/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</profile>
</profiles>
However, that configuration was not working on the build server. There were attempts made to download artifacts from central maven repository.
I've found out that there, in settings.xml, the repositories section was declared directly in <settings> and not in profile:
<settings>
<repositories>
<repository>
<id>central</id>
<url>https://internal.rep/nexus/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</settings>
which I've initially ignored, because it shouldn't make any difference. It did.
But why are repositories ignored, that are defined not in profile? There was no warning about invalid settings.xml, the maven behaved as if those tags were not there...
Do generally everything in settings.xml need to be declared in profile? I'm using Maven 3.8

How to prevent Maven from downloading artifacts from repository when I just update the pom version of my project

I'm using Maven as CI and JFrog Artifactory as a repository of my own artifacts and as a cache. Everything works fine. I'm using the Artifactory plugin in Jenkins to trigger artifact download and upload.
I cannot figure how to handle the following use case.
I have a multi-module project. In my Settings.xml I defined some snapshot, plugin, and release repositories.
In my local workspace, I upgraded the pom version of the parent project and its children. Then I made a local clean install. It failed because Maven was trying to download the artifacts of my project from Artifactory and they don't exist of course because I'm trying to create a new version of the project.
How to handle this use case? How to configure my pom or settings to do?
How to do this in the Artifactory plugin in Jenkins in a freestyle way?
I have error messages like this :
10:23:28 Failed to transfer Could not find metadata com.xxx.xxxx.xxx:my-parent-project:3.0.0-SNAPSHOT/maven-metadata.xml in xxx
10:23:50 [FATAL] Non-resolvable parent POM for com.xxx.xxxx.xxx:subpoject1:[unknown-version]: Could not find artifact .....and 'parent.relativePath' points at wrong local POM # line 7, column 10*
=====================================
pom configuration of the parent pom
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.xxx.xxx</groupId>
<artifactId>my-parent-project</artifactId>
<version>3.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>../subproject-1</module>
<module>../subproject-2</module>
</modules>
==================================
pom configuration for subproject1
<artifactId>subproject-1</artifactId>
<parent>
<groupId>com.xxx.xxx.xxx</groupId>
<artifactId>my-parent-project</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
======================================
Here is my settings.xml configuration
<profile>
<id>artifactory_profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://xxxxxxxxxxxx:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://xxxxxxxxxxxx:8081/artifactory/libs-snapshot</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>sing</id>
<name>sing-virtual-repo</name>
<url>http://xxxxxxxxxxxx:8081/artifactory/virtual-repo</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://xxxxxxxxxxxx:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-release</name>
<url>http://xxxxxxxxxxxx:8081/artifactory/plugins-release</url>
</pluginRepository>
</pluginRepositories>
</profile>
If you run clean install on the parent POM, then everything will be created correctly.

Configure jcenter for only downloading artifacts and Artifactory for deploying artifacts

We have Artifactory setup and we use Maven central repo for downloading artifacts, which are then automatically cached in Artifactory. We also upload/deploy our own artifacts in Artifactory.
I now want to replace Maven central repo with jcenter and would like to continue using our Artifactory for uploading/deploying our own artifacts and for also caching the jcenter (and any third-party) artifacts. I can ask all developers to modify their settings.xml file as it will be a one-time activity so that's not a problem.
I saw this link by #helmedeiros which describes making changes in <repositories> and <pluginRepositories> section of settings.xml file. However, those are the sections where i specify URL for our Artifactory server. If i replace my Artifactory URL, then it would mean that i will be able to both fetch and upload artifacts from jcenter which is not what i want.
How can i ensure that all developers are only able to pull (NOT deploy/upload) from jcenter and deploy/upload ONLY to Artifactory?
Here's what we have right now in settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
<id>central</id>
</server>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://inhouse-artifactory/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://inhouse-artifactory/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>https://inhouse-artifactory/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>https://inhouse-artifactory/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
I will really appreciate any help in this regard.
I have exactly the same question :)
My solution is to create an Artifactory virtual repository (forgerock-third-party-virtual) to cache most of the public artifacts.
This virtual repository includes a remote repository based on jcenter:
On the virtual repository, there is no default deployment repository:
So with this setting, I hope the developers won't be able to push in this virtual repository.
According to the JFrog documentation, you have select one repository in this drop-down to be able to push into a virtual repository.
Regarding the deployment settings, we also have a parent pom where we specified our own repositories in the <distributionManagement> section.
On my build machines, I've added this profile (in .m2/settings.xml) to cache the artifacts:
<profile>
<id>force-third-party-repo</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>forgerock-third-party</id>
<name>ForgeRock Third Party Repository</name>
<url>http://maven.forgerock.org/repo/forgerock-third-party-virtual</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>forgerock-third-party</id>
<name>ForgeRock Third Party Repository</name>
<url>http://maven.forgerock.org/repo/forgerock-third-party-virtual</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
I have other settings in this file to declare our own Artifactory repositories (for pushing/pulling our own artifacts) + some Maven credentials.
I did some tests with one of our Maven projects and it was working fine.
Once the new .m2/settings.xml will be ready, I'll push a template in an internal Artifactory repository, so the developers will be able to get this template with a curl command.
FYI, this is a POC for the moment. We want to move in production with these settings in a few days.

Maven archetype catalog : specify custom location(s)

I'm deploying a Nexus repository for Maven, and custom archetypes on it.
I would like to execute mvn archetype:generate and be prompted a list of internal + custom archetypes.
The only way I found to prompt custom archetypes (in an ergonomic way, meaning no URL) is to define the archetype-catalog path as a property in the settings. This is not a valid solution because I want several catalogs (and this property cannot be overriden in CLI).
Does anybody have a clue on how to do that ?
Thanks in advance,
[EDIT]
I found an issue report related : http://jira.codehaus.org/browse/ARCHETYPE-273
And I noticed that during archetype:generate, maven tries to reach the central repository :
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2
It ends by a "Connection Timed out" because I did not (and don't want to) specify a proxy...
I don't understand why maven doesn't check nexus catalog...
I also have a Nexus configured to mirror the Maven repositories and thus the remote catalog too.
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://afbwt03:8081/nexus/content/groups/JavaRepo/</url>
</mirror>
and:
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
I am able to access the remote catalog only when I use the following Maven command line:
mvn archetype:generate -DarchetypeCatalog=http://afbwt03:8081/nexus/content/groups/JavaRepo
If I don't define the archetypeCatalog variable, I get the same behavior as you do: trying to access the repo1. ... although some mirrors are configured.
You need to have
the property archetypeRepository defined in the active profile in your .m2/settings.xml
the repositories and pluginRepositories redirected to your mirror, on the same id "central".
and of course, the mirror defined
Apache maven documentation on archetype plugin specifies that archetypeRepository is definable user property:
http://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html
Your .m2/settings.xml should have these minimal elements
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>central</id>
<name>Mirror for maven central</name>
<url>http://mymvnhost:8081/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>dev</id>
<properties>
<archetypeRepository>http://mymvnhost:8081/nexus/content/groups/public/</archetypeRepository>
</properties>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
</settings>
With maven-archetype-plugin:3.1.1 you have to
add/edit archetype-catalog.xml on your repo to list your custom archetypes
edit your settings.xml to add this repo with id archetype.
invoke mvn archetype:generate -DarchetypeCatalog=remote
From https://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html :
If you want the catalogs to come from a different repository, please add the following to your settings.xml
<repository>
<id>archetype</id>
<url>https://repository.domain.com/path/to/repo/</url>
</repository>

mvn:install to place my jar in nexus remote repository

I am using maven in eclipse (m2 eclipse)
When i execute mvn:install i want my jar(artifact) to be installed in the nexus repository which is located on the server(right now the installed jar is placed in the local system repository).. how can i do that ?
I even changed this to my local repository address
Typically, you'd use mvn deploy to deploy to a non-local repository.
You will, of course, need to have the repo configured, either in your maven settings.xml or in the project POM.
As we always use the same internal repo, I've done this in the Maven settings.xml, more precisely, the "profiles" section.
Here is my config for reference:
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<id>central</id>
<name>libs-releases</name>
<url>http://repo.example.com/libs-releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<name>libs-snapshots</name>
<url>http://repo.example.com/libs-snapshots</url>
<snapshots />
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>plugins-releases</name>
<url>http://repo.example.com/plugins-releases</url>
<snapshots><enabled>false</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>

Resources