Maven: Warning if dependency if artefact is not found - maven

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.

Related

Maven make project offline and repository in project folder

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?

Difference between repository and pluginrepository

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.

Get dependencies from multiple repo's

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.

maven repository eclipse project

A quick question.
A am new to pom repositories.
I added this
<repository>
<id>tapx</id>
<name>howard lewisship snapshot repository</name>
<url>http://howardlewisship.com/snapshot-repository/</url>
</repository>
to pom file to get these files for tapestry project.
sha1 left and filename ont the right
7155233ba0dfbd99e19358f57e262ad484a440c6 tapx-core-1.1-20110620.210912-27.jar
822c300e6b6d93c53216d8d4fbb9b13217a7fb84 tapx-core-1.2-20110705.222421-4.jar
c11b3134128c3267f55dc4f8bfaab2f1f68ba711 tapx-datefield-1.1-20110617.214353-17.jar
ba2f05929baf2c01d22300953e983ac7a8f791b5 tapx-datefield-1.2-20110705.222544-4.jar
rebuild the index for added project repository
in eclipse when i enter sha1sum on the dependency searcher in eclipse i get 0 results.
Please tell me what i did wrong?
Enable snapshots; IIRC they're disabled by default.
<repository>
<id>tapx</id>
<name>howard lewisship snapshot repository</name>
<url>http://howardlewisship.com/snapshot-repository/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
Also see this super-POM reference info.

Unable to get dependency in an internal repository

We are using Maven 3.0.3. We have deployed a JAR file to an internal repository at
http://maven/maven_repo/repositories/release/org/openqa/selenium/server/selenium-server/0.9.2/selenium-server-0.9.2-standalone.jar
I have then included this dependency ...
<dependency>
<groupId>org.openqa.selenium.server</groupId>
<artifactId>selenium-server</artifactId>
<version>0.9.2</version>
<scope>test</scope>
</dependency>
Also, in my ~/.m2/settings.xml file, I have our internal repository ...
<repository>
<id>mycoInternalRelease</id>
<layout>default</layout>
<name>myco Internal Repository</name>
<url>http://maven/maven_repo/repositories/release</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<checksumPolicy>fail</checksumPolicy>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
Despite all this, when I run my pom, I get the error
[ERROR] Failed to execute goal on project myco-productplus-web: Could not resolve dependencies for project myco-productplus:myco-productplus-web:war:1.0-SNAPSHOT:The following artifacts could not be resolved: org.openqa.selenium.server:selenium-server:jar:0.9.2, org.openqa.selenium.server:selenium-server-coreless:jar:0.9.2: Could not find artifact org.openqa.selenium.server:selenium-server:jar:0.9.2 in mycoInternalRelease (http://maven/maven_repo/repositories/release) -> [Help 1]
[ERROR]
How can I heal the pain? Thanks, - Dave
Given your artifact is named "selenium-server-0.9.2-standalone.jar" you might need to add <classifier>standalone</classifier> to your dependency declaration in your pom.

Resources