I am creating parent-pom. There we are defining build->plugin->dependencies.
It can fetch dependencies from maven but it couldn't fetch dependencies from our internal Maven repository. getting below error
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-antrun-plugin:1.2:check (validate) on
project parent-pom: Execution validate of goal
org.apache.maven.plugins:maven-antrun-plugin:1.2:check failed: Plugin
org.apache.maven.plugins:maven-antrun-plugin:1.2 or one of its
dependencies could not be resolved: Could not find artifact
org.tools:build-tool:jar:1.0 in central
(https://repo.maven.apache.org/maven2) -> [Help 1]
It is trying to pull dependency from https://repo.maven.apache.org/maven2 instead of our internal Maven repository. I have configured repositories and dependencyManagement still it is trying to fetch from https://repo.maven.apache.org/maven2 instead of going to our internal repositories.
pom.xml
<?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>org.global</groupId>
<artifactId>parent-pom</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<repositories>
<repository>
<id>archiva.global</id>
<name>Internal Release Repository</name>
<url>https://archiva.global.com/repository/internal</url>
</repository>
<repository>
<id>archiva.snapshots</id>
<name>Internal Snapshots Repository</name>
<url>https://archiva.global.com/repository/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>archiva.internal</id>
<name>Internal Release Repository</name>
<url>https://archiva.global.com/repository/internal</url>
</repository>
<snapshotRepository>
<id>archiva.snapshots</id>
<name>Internal Snapshots Repository</name>
<url>https://archiva.global.com/repository/snapshots</url>
</snapshotRepository>
</distributionManagement>
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
...
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.tools</groupId>
<artifactId>build-tool</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
...
</project>
Is there anything I missed? Only build plugin dependencies are not resolved where as project dependencies are getting resolved from our internal repository.
It is the default behavior of maven.
When defining <repository> .... </repository> make sure to override the <id>central</id> with your internal repository. If you don't do so, maven will still contact maven central to resolve dependencies and not work without proper proxy settings if you are behind a VPN. The below listing will fetch all your deps from your internal repository.
<repositories>
<repository>
<id>central</id>
<name>Internal Release Repository</name>
<url>https://archiva.global.com/repository/internal</url>
</repository>
<repository>
<id>archiva.snapshots</id>
<name>Internal Snapshots Repository</name>
<url>https://archiva.global.com/repository/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
For downloading the plugins from your internal repository
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Internal Repo</name>
<url>https://archiva.global.com/repository/internal</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
Related
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
I am currently involved in a project managed by maven and the project structure is a mess. So I tried to update the pom files and settings.xml first.
However after I switched in settings.xml:
<repository>
<id>Spring IO Releases</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>Spring IO Snapshots</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
to:
<repository>
<id>Spring IO Snapshots</id>
<url>http://repo.spring.io/libs-snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>Spring IO Releases</id>
<url>http://repo.spring.io/libs-release/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
And changed my dependency from:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.XXX</artifactId>
<version>${spring-version}</version>
</dependency>
to
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-XXX</artifactId>
<version>${spring-version}</version>
</dependency>
However it didn't work. What is the difference between these two dependencies?
I have checked inside the Jar files and only obvious thing is springframework.XXX artifacts are build 1 month before spring-XXX artifact contents.
How can i use selenium and sikuli in one pom.xml ?
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
sikuli is in :
<repository>
<id>com.sikulix</id>
<name>com.sikulix</name>
<url>https://oss.sonatype.org/content/groups/public</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
but adding this repo, makes maven to look there for selenium too
is it possible to link two different dependencies from two different repositories ?
Maven looks for artifacts (selenium, sikulixapi, ..) in all defined repositories.
You can define two: com.sikulix and the standard one:
<repositories>
<repository>
<id>com.sikulix</id>
<name>com.sikulix</name>
<url>https://oss.sonatype.org/content/groups/public</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
I am trying to get Apache commons-io-2.4.jar installed directly using maven.
The POM snippet is as follows. Can anyone help me make it work?
POM Snippet:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
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>