Maven can't recognize the dependencies in both local and server - maven

The dependencies already be available in both local and server, but maven build(clean, install) still failed and complain that can't find them.
1> Although the dependency can be found in server, but failed to build online
Downloading: http://repo1.maven.org/maven2/org/codehaus/mojo/aspectj-maven-plugin/1.4/aspectj-maven-plugin-1.4.pom
[WARNING] Unable to get resource 'org.codehaus.mojo:aspectj-maven-plugin:pom:1.4' from repository central (http://repo1.maven.org/maven2): (http://repo1.maven.org/maven2%29:) Authorization failed: Access denied to: h
ttp://repo1.maven.org/maven2/org/codehaus/mojo/aspectj-maven-plugin/1.4/aspectj-maven-plugin-1.4.pom
2> I try to try offline, as the dependency is already in local, but failed
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
GroupId: org.codehaus.mojo
ArtifactId: aspectj-maven-plugin
Version: 1.4
Reason: System is offline.
org.codehaus.mojo:aspectj-maven-plugin:pom:1.4
3> BTW, i have configured the relevant profile for the server

You're likely behind a proxy that needs authentication.
To run Maven in offline mode do mvn -o clean install

Related

GCLOUD Artifact Registry: Permissions error downloading maven dependency uploaded manually with Cloud Build

I have uploaded manually an maven dependency to my artifact repository
From my local PC, "mvn install" download correctly every maven dependency from the artifact repository, included my manually uploaded dependency.
mvn -U clean install -DskipTests=true
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.healthcentrix.prevvy:frontend >------------------
[INFO] Building frontend 2.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from cloud-artifacts: artifactregistry://us-central1-maven.pkg.dev/prevvy1/artifacts/org/moxieapps/gwt/highcharts/1.7.2/highcharts-1.7.2.pom
Downloaded from cloud-artifacts: artifactregistry://us-central1-maven.pkg.dev/prevvy1/artifacts/org/moxieapps/gwt/highcharts/1.7.2/highcharts-1.7.2.pom (401 B at 90 B/s)
Downloading from cloud-artifacts: artifactregistry://us-central1-maven.pkg.dev/prevvy1/artifacts/org/moxieapps/gwt/highcharts/1.7.2/highcharts-1.7.2.jar
Downloaded from cloud-artifacts: artifactregistry://us-central1-maven.pkg.dev/prevvy1/artifacts/org/moxieapps/gwt/highcharts/1.7.2/highcharts-1.7.2.jar (521 kB at 376 kB/s)
From Cloud Build or cloud-build-local, we got an permission error
[ERROR] Failed to execute goal on project frontend: Could not resolve dependencies for project com.healthcentrix.prevvy:frontend:jar:2.1-SNAPSHOT:
Failed to collect dependencies at org.moxieapps.gwt:highcharts:jar:1.7.2:
Failed to read artifact descriptor for org.moxieapps.gwt:highcharts:jar:1.7.2:
Could not transfer artifact org.moxieapps.gwt:highcharts:pom:1.7.2 from/to cloud-artifacts (artifactregistry://us-central1-maven.pkg.dev/prevvy1/artifacts):
Permission denied on remote repository (or it may not exist).
The request had no credentials because none were available from the environment.
Ensure that either 1) You are logged into gcloud or 2) Application default credentials are setup (see https://developers.google.com/accounts/docs/application-default-credentials for more information). 403 Forbidden
Step #0: [builder] [ERROR] {"error":"Permission "artifactregistry.repositories.downloadArtifacts" denied on resource "projects/prevvy1/locations/us-central1/repositories/artifacts" (or it may not exist)"}
Our Cloud build Project service account has every Artifact Registry permission, and is downloading the rest of depedencies excluding this specific artifact, which was uploaded manually
is necessary to give some specific permissions to this specific artifact? how?
Thanks in advance for any guidance
Regards

Jenkins Deploying to local maven repository

I'm trying to deploy my artifacts to my local maven repository, but I keep running into issues. I have a Post-build Action defined to deploy my artifact to the following url: file:///home/nick/.m2/repository/ but I keep getting the following failed build message:
[JENKINS] Archiving /var/lib/jenkins/workspace/ouPerson/pom.xml to edu.oakland.ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/ouPerson/target/ouPerson-0.2.0.jar to edu.oakland.ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.jar
channel stopped
Maven RedeployPublisher use remote maven settings from : /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/_home_nick_bin_maven/conf/settings.xml
[INFO] Deployment in file:///home/nick/.m2/repository/ (id=ouPerson,uniqueVersion=true)
Deploying the main artifact ouPerson-0.2.0.jar
Uploading: file:///home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.jar
Uploading: file:///home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.pom
ERROR: Failed to deploy artifacts: Could not transfer artifact edu.oakland.ouPerson:ouPerson:jar:0.2.0 from/to ouPerson (file:///home/nick/.m2/repository/): Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact edu.oakland.ouPerson:ouPerson:jar:0.2.0 from/to ouPerson (file:///home/nick/.m2/repository/): Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:193)
at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:176)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:756)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1040)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:669)
at hudson.model.Run.execute(Run.java:1735)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact edu.oakland.ouPerson:ouPerson:jar:0.2.0 from/to ouPerson (file:///home/nick/.m2/repository/): Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:341)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:269)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
... 11 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact edu.oakland.ouPerson:ouPerson:jar:0.2.0 from/to ouPerson (file:///home/nick/.m2/repository/): Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1016)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1004)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:895)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:522)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:335)
... 14 more
Caused by: org.apache.maven.wagon.TransferFailedException: Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
at org.apache.maven.wagon.AbstractWagon.createParentDirectories(AbstractWagon.java:264)
at org.apache.maven.wagon.providers.file.FileWagon.fillOutputData(FileWagon.java:100)
at org.apache.maven.wagon.StreamWagon.getOutputStream(StreamWagon.java:188)
at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:159)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:871)
... 16 more
[INFO] Deployment failed after 0.13 sec
Build step 'Deploy artifacts to Maven repository' changed build result to FAILURE
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: FAILURE
Any ideas what I may be missing?
Ok, I figured out the reason why it wasn't working. I originally installed maven via apt-get, however after having issues deploying, I decided to download the war file on jenkins website and dropped the war into $TOMCAT_HOME/webapps and then I was able to deploy to local maven repository without any issues. Hope that helps those that are having similar issues!
try
mvn install
This will install your artifact to your LOCAL maven repo.
If you build your Jenkins job with maven, you have Top-Maven Target. Add this to your job with goals
clean install
Don't forget add pom.xml in advance

Does maven need Internet connection?

I try to build a project by maven.I tried
$ mvn archetype:generate -DgroupId=org.thoughtworks.app -DartifactId=mvntest -DarchetypeArtifactId=maven-archetype-quickstart
It worked.And then I tried
$ mvn archetype:generate -DgroupId=org.thoughtworks.app -DartifactId=mvntest
I mean,I delete archetypeArtifactId parameter.It fail,I didn't supply it with Internet.the error message is here.Is this parameter made it need Internet?Forget about other depedency.
[INFO] artifact org.apache.maven.archetypes:maven-archetype-quickstart: checking for updates from central
[WARNING] repository metadata for: 'artifact org.apache.maven.archetypes:maven-archetype-quickstart' could not be retrieved from repository: central due to an error: Error transferring file: repo1.maven.org
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] The desired archetype does not exist (org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE)
After you have all the dependencies downloaded on your local repository, then you can run mvn command with -o (offline) option and it should work, unless you don't need any other dependency from the remote repository (when the internet connection is needed).
If you have a repository with all the dependencies needed in your network you can reach on without the outside internet connection, just edit your settings.xml for your intranet dependencies.

Maven missing project required libraries after cloning repo

A team member has shared his project with me on bitbucket and he used maven to manage his dependencies. After cloning the repo (using mercurial) into my workspace (Eclipse) and downloading maven, m2e and all the other required set up files i was able to get all of the project libraries except for 4.
After downloading the project, i ran several mvn commands to clean, install and hopefully download these missing jars. When i ran mvn -e command i get this long error that does nothing to help. Do i have to find and download these 4 jars and put them in my maven repo?
Command output: mvn -e
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.769s
[INFO] Finished at: Mon Apr 09 17:42:17 CDT 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Dugsi_Manager: Could not resolve depen
dencies for project org.bixin.dugsi:Dugsi_Manager:war:0.1.0.BUILD-SNAPSHOT: The
following artifacts could not be resolved: org.eclipse.persistence:eclipselink:j
ar:2.2.0, org.eclipse.persistence:javax.persistence:jar:2.0.3, org.vaadin:icepus
h-gwt:jar:0.1.2, org.jqurantree:jquran:jar:1.0.0: Could not find artifact org.ec
lipse.persistence:eclipselink:jar:2.2.0 in spring-maven-release (http://maven.sp
ringframework.org/release) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
EDIT:
I just need to share my local repository with all other team members that clone my project. External jars that dont use maven have to be manually installed into my local repo, this creates a problem because i cant share my local repo? Any ideas
You can either install these JARs in your local repository, or setup an own (possibly private) maven repository for you to share with your team. Sonatype provides with Nexus OSS an open-source based software to easily set up a repository (which also proxies remote ones if you like).

Jenkins (hudson) plugin development meet maven-enforcer-plugin:1.1-SNAPSHOT issue

I try to develop one jenkins (a.k.a hudson) plugin, and follow the Tutorial, and generated source code tree after mvn -cpu hpi:create command.
While when I do "mvn package", it reports error like
[INFO] Building Unnamed - com.example.jenkins:redmine2:hpi:1.0-SNAPSHOT
[INFO] task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.apache.maven.plugins:maven-enforcer-plugin
Reason: Error getting POM for 'org.apache.maven.plugins:maven-enforcer-plugin' from the repository: Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.
org.apache.maven.plugins:maven-enforcer-plugin:pom:1.1-SNAPSHOT
from the specified remote repositories:
nexus (http://maven.nexus.local:8888/nexus/content/groups/public)
for project org.apache.maven.plugins:maven-enforcer-plugin
From my nexus server, it has maven-enforcer-plugin:1.0 version only, but this dependence is generated from jenkins by default, anyone can help me to solve it ?
(How) Can I change to plugin-1.0 version.
what can I add in nexus server
I just have basic knowledge of maven.
I fixed it by myself by doing two things.
1. Added Apache snapshot from here into my nexus repo group besides those setting in Tutorial
2. It seems my local maven repo is messed up as well, so I can clean it up and reload from nexus.
And it still use maven-enforcer-plugin:pom:1.1-SNAPSHOT plugins.
Hope it helps you as well.

Resources