MuleSoft Maven Build Failure Using TFS Build Release - maven

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.

Related

RED lines in Maven POM [duplicate]

The development machine cannot access the internet, and take about 60s to timeout. When I try to build, I see
Downloading: http://repo.maven.apache.org/maven2/com/google/gsa-connector/2.8.0/gsa-connector-2.8.0.pom
However, I have the following in my POM:
<repository>
<id>bb-nexus</id>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>nexus-3rdparty</id>
<url>http://repo.dev.bloomberg.com/content/repositories/thirdparty/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
It always tries to go to repo.maven first. I even tried to add to D:\.m2\settings.xml
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
</mirror>
</mirrors>
based on http://maven.apache.org/guides/mini/guide-mirror-settings.html yet it continues to try repo.maven first. I'm using Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
I can't use -o because it still needs to access the local repo.dev.
Here is with 'effective-settings':
D:\Users\chloe\Projects\team\confluence-plugin>mvn help:effective-settings
[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-install-plugin/maven-metadata.xml from/to central (
http://repo.maven.apache.org/maven2): Connection to http://repo.maven.apache.org refused
...
[INFO]
[INFO] --- maven-help-plugin:2.1.1:effective-settings (default-cli) # bb-confluence-plugin ---
[INFO]
Effective user-specific configuration settings:
<?xml version="1.0" encoding="UTF-8"?>
...
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoca
tion="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<localRepository xmlns="http://maven.apache.org/SETTINGS/1.1.0">d:\.m2\repository</localRepository>
<pluginGroups xmlns="http://maven.apache.org/SETTINGS/1.1.0">
<pluginGroup>org.apache.maven.plugins</pluginGroup>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups>
</settings>
[INFO] ------------------------------------------------------------------------
All pom files inherit from the maven super POM
http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html
which contains this entry:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Try setting this in your pom (with <id>central</id>):
<repositories>
<repository>
<id>central</id>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
Overriding the central repository
How it works:
Most organizations will need to set up one or more shared repositories, since not everyone can deploy, or simply download from the central Maven repository.To publish releases for use across different environments within their network, organization's will typically want to set up what is referred to as an internal repository.
When using this repositories for your projects, there are two choices: use it as a mirror, or have it override the central repository. You would use it as a mirror if it is intended to be a copy of the central repository exclusively, and if it's acceptable to have developers configure this in their settings. Or like in this case that you want to prevent access to the central repository for greater control, to configure the repository from the project level instead of in each user's settings, or to include your own artifacts in the same repository, you should override the central repository.
Also, Is very important to have in mind, at this point, the resolution process conducted by the maven dependencies, which have two main blocks settings for repositories:
related to the decencies will be listed within us ;
related to plugins that will be added within the nodes or used during the life cycle.
The Solution:
As an object oriented framework Maven has all POMs have an implicit parent the Super POM. Under its definitions lay down both dependencies and plugins first resolver repositories configurations:
<repositories>
<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>
</pluginRepositories>
To override the central repository with your internal repository, you must define a repository in a settings file and/or POM that uses the identifier central (<id>central</id>). Usually, this must be defined as both a regular repository and a plugin repository to ensure all access is consistent. For example:
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
Related link: Coderwall - Stopping maven from trying to access its Central Repository
Try setting the following in the reporting/plugins block
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>

How to connect mule repository?

I'm getting below when i run my mule interface.
[ERROR] Failed to execute goal on project apl-integration: Could not resolve dependencies for project com.katalystm:apl-integration:mule:1.0.0-PRE: Failed to collect dependencies at com.mulesoft.muleesb:mule-core-ee:jar:3.7.0: Failed to read artifact descriptor for com.mulesoft.muleesb:mule-core-ee:jar:3.7.0:
Could not transfer artifact com.mulesoft.muleesb:mule-core-ee:pom:3.7.0 from/to mulesoft-releases (http://repository.mulesoft.org/releases/): Connect to repository.mulesoft.org:80 [repository.mulesoft.org/52.7.200.18] failed: Connection timed out: connect -> [Help 1]
Seem it is failed to connect the http://repository.mulesoft.org/releases/, i have added the repository even in my POM file aslo.
<repositories>
<repository>
<id>Central</id>
<name>Central</name>
<url>http://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots</id>
<name>MuleSoft Snapshots Repository</name>
<url>http://repository.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
</repositories>
Please add this repository
<repository>
<id>codehaus-mule-repo</id>
<name>codehaus-mule-repo</name>
<url>
https://repository-master.mulesoft.org/nexus/content/groups/public/
</url>
<layout>default</layout>
</repository>

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?

How to add Authorizarion for Archiva Repositoty in Maven?

I am using Maven for my project everything work fine but now i need some third party jar which are not available on Maven Central repository.
So i installed Archiva in my server and added Archiva repository entry in pom.xml file
<repository>
<id>internal</id>
<name>Archiva Managed Internal Repository</name>
<url>http://ipaddress:8888/repository/internal/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
But when i am running mvn command i am getting
> Could not transfer artifact
> org.jbosscaches:jboss-common-core:pom:2.2.19.GA from/to internal
> (http://ipaddress:8999/repository/internal/): Not authorized ,
> ReasonPhrase:Unauthorized. -> [Help 1
What changes i have to do maven settings.xml file
Have a look at this http://archiva.apache.org/docs/2.1.0/userguide/deploy.html.
I'm pretty sure this will help you :-)
Olivier

How to configure Hudson to point to local repository instead of central one?

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

Resources