I try to make my Project offline and build the project with an in-project-repo. So the ~/.m2/ directory is empty at the beginning. I added the following into my poms:
<repositories>
<repository>
<id>project</id>
<url>file://${basedir}/lib</url>
</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>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>project</id>
<url>file://${basedir}/lib</url>
</pluginRepository>
</pluginRepositories>
Then I deleted everything in my .m2 folder and build my project with internet with the option
-dependency:go-offline
This works. Then I copy everything out of the .m2/repository directory into my lib directory in my project and delete the content in .m2/repository. Now I disconnect from the internet and try to build my project with the option -o. This dont work and I get the following error:
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: The repository system is offline but the artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 is not available in the local repository. -> [Help 1]
In my lib folder(in-project-repo) exist this plugin and all the other plugins.
I have some sources who are not availbable in the internet. I copyed them to my lib folder(in-project-repo) and they get copyed into the local m2 repository when I build my project. So I guess my in-project-repo is working. I don't understand this.
If I let the content int the ~/.m2 folder I can build my project without internet.
I hope someone can help me!
Kindly Regards
EDIT: I made it work with the option:
-Dmaven.repo.local=/path/to/project/lib clean package -X -o
Is there a better way?
Related
We are using TFS GIT and trying to build the project and getting below error (the same code works fine on my local when i do mvn clean install but fails in tfs server):
Unresolveable build extension: Plugin org.mule.tools.maven:mule-maven-plugin:3.3.5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.mule.tools.maven:mule-maven-plugin:jar:3.3.5 -> org.mule.tools.maven:mule-packager:jar:3.3.5 -> org.mule.tools.maven:mule-classloader-model:jar:3.3.5 -> commons-io:commons-io:jar:2.6: Failed to read artifact descriptor for commons-io:commons-io:jar:2.6: Could not transfer artifact commons-io:commons-io:pom:2.6 from/to central (http://repo1.maven.org/maven2): Failed to transfer file http://repo1.maven.org/maven2/commons-io/commons-io/2.6/commons-io-2.6.pom with status code 501 -> [Help 2]
2020-07-01T16:27:19.7473940Z org.apache.maven.plugin.PluginManagerException: Plugin org.mule.tools.maven:mule-maven-plugin:3.3.5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.mule.tools.maven:mule-maven-plugin:jar:3.3.5 -> org.mule.tools.maven:mule-packager:jar:3.3.5 -> org.mule.tools.maven:mule-classloader-model:jar:3.3.5 -> commons-io:commons-io:jar:2.6
Agree with khmarbaise.
I encountered into the same problem when I used Central Repository with http communication.
To solve this issue, you need to change the reference of Central Repository in the Pom file to https communication.
For example:
<Project>
....
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
....
</project>
Then the Maven task could work as expected.
Hope this helps.
I'm a novice in Hudson and need it for automation in building the project. After installing Hudson-3.0.1, i tried building one of the projects manually. I keep getting this error.
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Could not find artifact com.bnpparibas.parent:bnpparibas-parent:pom:1.0.1 in central (http://repo1.maven.org/maven2) and 'parent.relativePath' points at wrong local POM # line 41, column 10
I understand that it is looking for the artifact in the central repository rather than in my local. I don't know how to configure hudson to refer to local repository. All my google searches didn't yeild much useful information. Can somebody help me on this?
Redefine "central" repository in your pom:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localAddress[:localPort]/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localAddress[:localPort]/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://localAddress[:localPort]/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://localAddress[:localPort]/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
Or add more repositories section to your pom
<repository>
<id>localRepo</id>
<name>libs-release</name>
<url>http://localAddress[:localPort]/artifactory/libs-release</url>
</repository>
Or if you have all artifacts in local repo (.m2/repository/) run compilation in off-line mode:
mvn -o clean install
My Android Maven project pom.xml contains the following entries. Now everything works fine. What is the difference between <repositories> entries and the <pluginRepositories> entries.
<repositories>
<repository>
<id>my-repo</id>
<url>http://10.10.10.230:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>my-repo</id>
<name>my-repo</name>
<url>http://10.10.10.230:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
As #otakun85 stated, There is no technical difference at all. It's for having different configurations->behavior for plugins in contrary to normal artifacts. See repository vs. pluginRepository for more details.
Also check maven-users mailing list archives, It provides quite good explanation to it.
Maven will resolve plugin dependencies using the configured pluginRepository. Other artifact dependencies (eg. a parent pom) are resolved using repository.
Note: Things available on maven central will be resolved by default so you wouldn't normally need to include repository for those.
For example, if your pom.xml specifies a parent pom and a plugin dependency that both exist in the same repository you must still specify both repository AND pluginRepository. If you only configure one then maven will complain with "Unresolvable X" errors.
Is it possible to download dependencies in maven using multiple plugin-repos?
I have my settings.xml configured to get dependencies from a custom repo and because of this, i am unable to get dependencies from the main maven repo server.
Is this possible to setup more then one plugin Repo?
Here is what i have setup so far for my custom repo:
</profiles>
<profile>
<id>custom-config</id>
<repositories>
<repository>
<id>custom-snapshots</id>
<name>customSnapshots</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http:/custom/repo</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>custom-plugins</id>
<urlhttp:/custom/repo/public-snapshots</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
I have not included the dependencies here, but I am unable to pull and resolve some library dependencies.
The maven repo that I use is http://mvnrepository.com/ but I dont have details on the exact repo settings to use as the one I defined for a custom one.
The default maven repository is called "central". Its url is: http://repo1.maven.org/maven2/ or nowadays: http://repo.maven.apache.org/maven2/
But it is usually configured as mirrorOf. If you create a repository in your settings.xml and give it the id *central" it will replace it.
So I wonder why you can't resolve dependencies from there. Usually adding a repository in settings.xml does not turn of central.
could you execute mvn help:effective-settings and mvn help:effective-pom and have a loook at all repositories, profiles and mirrorOf elements in the xml? central should be there.
I would also recommend using a Maven proxy like Nexus or Artifactory. It simplifies a lot of things within a company.
Can I add option to Maven to say WARNING if some artefact wasn't found in some repository. Let's I have
<repositories>
<repository>
<id>main</id>
<name>main-repo</name>
<url>http://repourl</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
But Maven not find some dependency of dependency in repo. Then he say WARNING in log. Can I do it?
A have in my company's repo resource 'org.apache.cxf:cxf-rt-frontend-jaxrs:pom:2.5.4'. But I havn't dependencies. This resource was copied to my JAR file. But no one dependency of 'cxf-rt-frontend-jaxrs' wasn't intsalled. In log
[INFO] Unable to find resource 'org.apache.cxf:cxf-rt-frontend-jaxrs:pom:2.5.4' in repository MAIN (http://url/)
Downloading: http://url//org/apache/cxf/cxf-rt-frontend-jaxrs/2.5.4/cxf-rt-frontend-jaxrs-2.5.4.pom
But no warning about dependencies of cxf-rt-frontend-jaxrs
Dependencies of cxf-rt-frontend-jaxrs are declared in org.apache.cxf:cxf-rt-frontend-jaxrs:pom:2.5.4 artifact, which Maven was not able to find. So, answer to your question is it can't be done.