1

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.

5
  • What is org.tools:build-tool:jar:1.0 Commented Jul 30, 2021 at 9:20
  • @SimonMartinelli It is in our internal archiva repository. https://archiva.global.com/repository/internal. I defined in <repositories> and <distributionManagement> section. Commented Jul 30, 2021 at 9:21
  • It is there in our internal archiva repository org.tools:build-tool:jar:1.0 . It is internal for our project so we cannot find this in Maven central Commented Jul 30, 2021 at 9:23
  • Can you ckeck if the plugin jar file was downloaded in the respective directory in M2? Sometimes there are only metadata files and not the jar. Commented Jul 30, 2021 at 9:25
  • Nope, it is not there...As I mentioned in the question it is not pulling it from the remote repo. It is trying to pull it from Maven central. Commented Jul 30, 2021 at 9:28

1 Answer 1

2

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> 
Sign up to request clarification or add additional context in comments.

8 Comments

Now we are getting the followig exception dependencies could not be resolved: Could not find artifact org.tools-tool:jar:1.0 in central (repo1.maven.org/maven2)
Use <id>central</id> for the repository as well as the plugin repository because even the maven plugins need to be downloaded. as well as in your distribution management use central for id tag. also, make sure to not use snapshots for testing purposes.
What do you mean by plugin repository? I have defined repositories I believe that's sufficient. Yes, I modified distribution Management to the central still the same issue.
you can also check if the repo is reachable archiva.global.com/repository/internal/org/tools/build-tool
It is reachable. As I mentioned it cannot able to resolve only dependencies we defined in build->plugins-> plugin.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.