Maven activeProfiles are ignored? - java

I use for Eclipse a maven settings.xml that has a 3rd-party Artifactory location from which Maven artefacts are retrieved.
We added now an own Artifactory which hosts artefacts not contained in the former Artifactory.
We added new profiles to the settings.xml and activated them.
What happens now, if artefacts shall be retrieved that are only in the new one, the maven build fails with an artefact not found exception.
Looking through the debug-output it seems like Maven never tries to access the new location.
As test, we deactivated the profiles of the 3rd-party Artifactory. Now the debug-log shows that Maven tries to access our Artifactory (but only if there are no other locations than ours).
Has someone an idea why the new Artifactory is ignored if the other profiles are active?
Below is my settings.xml, the upper two "ltl-*" profiles are the new ones which seems to be not used.
<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">
<profiles>
<profile>
<id>ltl-releases</id>
<repositories>
<repository>
<id>ltl-releases</id>
<url>http://134.91.18.140:8081/artifactory/releases</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>ltl-snapshots</id>
<repositories>
<repository>
<id>ltl-snapshots</id>
<url>http://134.91.18.140:8081/artifactory/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>ukp-oss-releases</id>
<repositories>
<repository>
<id>ukp-oss-releases</id>
<url>http://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>ukp-oss-releases</id>
<url>http://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>ukp-oss-snapshots</id>
<repositories>
<repository>
<id>ukp-oss-snapshots</id>
<url>http://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>ltl-releases</activeProfile>
<activeProfile>ltl-snapshots</activeProfile>
<activeProfile>ukp-oss-releases</activeProfile>
<!-- Uncomment the following entry if you need SNAPSHOT versions. -->
<activeProfile>ukp-oss-snapshots</activeProfile>
</activeProfiles>
</settings>

Related

Error in downloading dependency from 2 mirrors in Maven

I want to download spring-native dependency from maven mirror as it is not in my third party mirror.I tried to do it by including maven mirror in my settings.xml file,but it doesn't work.
Settings.xml file-
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<id>artifactory</id>
<mirrorOf>*</mirrorOf>
<url>https://thirdparty.com/artifactory</url>
</mirror>
<mirror>
<id>MavenCentral</id>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>MavenCentral</id>
<url>https://repo.maven.apache.org/maven2/</url>
</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>artifactory</activeProfile>
</activeProfiles>
</settings>
I added this dependency-
<dependency>
<groupId>org.springframework.experimental</groupId>
<artifactId>spring-native</artifactId>
<version>0.9.2</version>
</dependency>
Issue-
Cannot resolve org.springframework.experimental:spring-native:0.9.2
How can I resolve this?
When you use <mirrorof>*<mirrorof> then you essentially override all other mirrors and repository definitions. To exclude repositories from the mirror, use
*,!otherrepo

Allow repository only for plugins?

Can I restrict Maven to use a given Nexus repository (group) only to resolve plugins and their dependencies (and not for dependencies of the project itself)?
At the moment, I use a settings.xml which mirrors everything in a "public" group:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<!--This sends everything to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://ik-repo:8080/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Now I would like to use a second group "pluginPublic" (in addition to "public") that is used to resolve the dependencies of the plugins.
The background is as follows: I want to allow certain dependencies to be used by Maven plugins but not allow every developer to access them for their build.
Yes, you can simply set up the pluginRepositores in your .m2/settings.xml
<repositories>
<repository>
<id>central</id>
<url>https://my.company/repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://my.company/plugin_repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
I ended up using a mirror for everything but the plugin repository group:
<settings>
<mirrors>
<mirror>
<!--This sends everything to /public -->
<id>nexus</id>
<mirrorOf>*,!pluginpublic</mirrorOf>
<url>http://ik-repo:8080/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</pluginRepository>
<pluginRepository>
<id>pluginpublic</id>
<url>http://ik-repo:8080/nexus/content/groups/pluginpublic/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

The POM for jar is missing no dependency information available

I get the following error
[WARNING] The POM for com.westgroup.caesar.uuid:wguuidJava:jar:1.0 is missing, no dependency information available
[WARNING] The POM for charliedog:argv:jar:0.0.1 is missing, no dependency information available
[WARNING] The POM for com.oracle:classes12:jar:10.1.0.5.0 is missing, no dependency information available
But these jars and pom files are downloaded into my local repository from central repository Nexus. When I run the command mvn clean install, I get the above error.
Maven settings.xml file:
<server>
<id>releases</id>
<username>abc</username>
<password>abc</password>
</server>
<server>
<id>snapshots</id>
<username>abc</username>
<password>abc</password>
</server>
<server>
<id>thirdparty</id>
<username>abc</username>
<password>abc</password>
</server>
<mirror>
<id>nexus-public-snapshots</id>
<mirrorOf>public-snapshots</mirrorOf>
<url>http://maven.int.westgroup.com:8081/nexus/content/groups/public-snapshots</url>
</mirror>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>Nexus Public Mirror</name>
<url>http://maven.int.westgroup.com:8081/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>nexus-third-party</id>
<mirrorOf>third-party</mirrorOf>
<url>http://maven.int.westgroup.com:8081/nexus/content/repositories/thirdparty/</url>
</mirror>
<profiles>
<profile>
<id>development</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>
<profile>
<!--this profile will allow snapshots to be searched when activated-->
<id>public-snapshots</id>
<repositories>
<repository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<!--this profile will allow snapshots to be searched when activated-->
<id>third-party</id>
<repositories>
<repository>
<id>third-party</id>
<url>http://thirdparty</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>third-party</id>
<url>http://thirdparty</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|-->
<activeProfiles>
<activeProfile>development</activeProfile>
<activeProfile>public-snapshots</activeProfile>
<activeProfile>third-party</activeProfile>
</activeProfiles>
I have uploaded these missing jars into Nexus repository into third-party repository.
wguuidJava jar and pom file in my local repository
Could you please let me know if I am missing any configuration in the settings.xml file?
Everything is fine. You have a WARNING, not an ERROR.
This warning is related to how the jar was built and uploaded to the repository. It does not affect functionality.
I hope this helps.

Can't find the maven repository for xwiki xmlrpc

I want to include this library:
import org.xwiki.xmlrpc.XWikiXmlRpcClient;
so I am using this maven snippet to include it:
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-core-xmlrpc-client </artifactId>
<version>2.1.1</version>
</dependency>
I can't find the library anywhere though. We use Artifactory which queries the main maven repo for unresolved dependencies. I can find the jar online, but I need a maven repository to include it in the build process.
Do I need to add a special repo or something?
A list can be found at at their website :
<repositories>
<repository>
<id>xwiki-snapshots</id>
<name>XWiki Nexus Snapshot Repository Proxy</name>
<url>http://nexus.xwiki.org/nexus/content/groups/public-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>xwiki-releases</id>
<name>XWiki Nexus Releases Repository Proxy</name>
<url>http://nexus.xwiki.org/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>xwiki-plugins-snapshots</id>
<name>XWiki Nexus Plugin Snapshot Repository Proxy</name>
<url>http://nexus.xwiki.org/nexus/content/groups/public-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>xwiki-plugins-releases</id>
<name>XWiki Nexus Plugin Releases Repository Proxy</name>
<url>http://nexus.xwiki.org/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

How to define a repository in Maven pom.xml

How can we define a repository in the pom.xml?
For example if dependency is not found in the repository defined in settings.xml then search for the dependency in the repository defined in pom.xml.
An example on how this can be achieved would be great.
I am aware that placing repositories in the pom.xml is not a good option, but circumstances are pushing for this.
<repositories>
<repository>
<id>java.net</id>
<url>https://maven.java.net/content/repositories/public/</url>
</repository>
</repositories>
From the documentation (example reproduced as is here):
<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">
...
<repositories>
<repository>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<id>codehausSnapshots</id>
<name>Codehaus Snapshots</name>
<url>http://snapshots.maven.codehaus.org/maven2</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
...
</pluginRepositories>
...
</project>

Categories

Resources