I have a project that is building fine on my laptop. Today I started to set up the build for this on our Bamboo server. Everything is checked in. Both my laptop and the build server are using Maven 3.0.4.
I have a top-level aggregator pom that specifies several modules, but this pom is not the parent of any module. I do use parent poms, but those parents are in peer submodules of the submodules that depend on them, and I have blank "relativePath" elements in all poms.
In the Bamboo build of the top-level aggregator POM, I see several errors like this:
[ERROR] The project com.example.cde:java-project-parent:1.0.1 (/volatile/bamboo/bamboo3.4.3_data/xml-data/build-dir/FOO-BUILD-JOB1/java-project-parent/pom.xml) has 1 error
18-Dec-2012 16:40:21 [ERROR] Non-resolvable parent POM: Failure to find com.example.cde:project-parent:pom:1.0.0 in http://hostname.net:8081/nexus/content/groups/stuff was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced and 'parent.relativePath' points at no local POM # line 6, column 11 -> [Help 2]
The "java-project-parent" is one of the poms in the parent hierarchy.
What I've discovered is that running "mvn install" in the top-level aggregator pom isn't actually installing the artifacts in the submodules. When I looked in the local repo, the only thing in each directory in the local repo was a file like "...pom.lastUpdated". The actual POM wasn't there.
When I had the admin manually run "mvn install" in the first submodule, that actually installed the POM into the local repo. I have a feeling if he manually installs the other two parent poms, the build of the project that depends on all three of them will build fine.
I must be misunderstanding an important detail of how a build with submodules works. What am I missing?
run maven clean install with Force update option as below:
mvn clean install -U
Your hierarchy is probably broken. You can test that by building it in your local machine after wiping the local repository. Most likely you will find the same failures as on the build machine.
To fix it I would suggest remove all the relative path elements and adjust the structure so a build will work fine. Ideally you even break the pure parent projects out into separate projects and release them into your repository manager so that any other builds get them from there..
Try doing a mvn -U install to force a mvn trip to your nexus repo for updated aritfacts
Also run mvn with the -e switch to see detailed error messages
Related
I have this log4j-1.2.12.jar file in my jenkins server
Path to it: /data/jenkins/.m2/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar I got this Apache Log4j Unsupported Version Detection message from security team, how to resolve this I tried downloading the latest version but it is something like this log4j-api-2.19.0.jar
No, it's not "in Jenkins", more accurately, log4j is not a part of Jenkins. Jenkins consumes its jars from the exploded war in ${JENKINS_HOME}/war/WEB-INF/lib. It is not located there.
If a plugin consumes log4j, that would be found within the exploded plugin directory at ${JENKINS_HOME}/plugins/<plugin_name>/WEB-INF/lib. The status of log4j as it related to most plugins was tracked under JENKINS-67353.
What you are referencing is the maven local repository, .m2/repository. This structure is created when running a maven build on the controller; the dependency jars specified in (one of) your build's pom.xml.
The guidance in the comments is correct; find the appropriate pom.xml and update it, then rebuild.
You can verify these claims by deleting the entire .m2 directory (or moving / zip;delete if you are paranoid) and restarting Jenkins. You'll discover Jenkins is running fine and the directory remains empty. Run your maven jobs and it will repopulate, including log4j-1.2.12.jar, assuming it's still specified in your pom.xml. Fix your maven pom.xml, delete the directory, rerun your jobs and it should not reappear.
Perhaps you have already updated your pom.xml but never cleared out your local maven repository, then it will not repopulate (you could check the timestamp of the directory to know when it was first/last downloaded).
You can also delete referenced portions of the repository by specifying mvn dependency:purge-local-repository and adding -DreResolve=false to avoid re-resolving. Of course, if you've already updated the pom.xml, it would remain since it's not referenced in the pom.xml` (yes, it would be nice if there was an option to purge all or most of a repository or all version of a given jar, but ...).
I am attempting to refactor a maven build process, and I am trying to populate a local maven repository to help with this refactor.
My build depends on obsolete versions of jar files that exist only in a maven repo on my network (not in maven central). Example: org.foo:example:1.7:jar
I have been attempting to run my maven build in a docker image image with the hope that I could identify all of the obsolete components being pulled from my maven repository.
My goal is to explicitly pull down dependencies from my maven repo and then build the application using only maven central as an external repository.
I have a docker file to run the build
FROM maven:3-jdk-8 as build
WORKDIR /build
# This pom.xml file only references maven central.
COPY pom.xml .
# Explicitly download artifacts into /root/.m2/...
RUN mvn dependency:get -Dartifact=org.foo:example:1.7.jar \
-DrepoUrl=https://my.maven.repo
# Run the build making use of the dependencies loaded into the local repo
RUN mvn install
Unfortunately, I see an error: could not resolve dependencies for project ... The following artifacts could not be resolved: org.foo:example:jar:1.7.
I presume there might be some metadata in my local org.foo:example:1.7:pom that has an awareness of its origin repository. I had hoped I could satisfy this dependency by pulling it into my local repository.
I also attempted to add the following flag
RUN mvn install --no-snapshot-updates
After further investigation, I discovered that the downloads in my .m2/repository contained files named _remote.repositories.
Solution: set -Dmaven.legacyLocalRepo=true when running dependency:get
With this flag, the _remote.repositories files are not created.
RUN mvn dependency:get -Dmaven.legacyLocalRepo=true \
-Dartifact=org.foo:example:1.7.jar \
-DrepoUrl=https://my.maven.repo
This question helped to provide a solution: _remote.repositories prevents maven from resolving remote parent
I have a question related to maven - generating a war. Please see below.
- In one of my project (war), I am using a 3rd party jar (-SNAPSHOT version) whose entry I have made into my project pom.xml. So far it gets bundled correctly into the project war.
- But we encountered one issue in one of the java file inside this jar. For which my developer took the source code for the jar and modified-compiled and updated the jar file into local maven_repo directory.
- But whenever I build the project using maven clean:install command, my updated jar gets deleted from my local maven-repo dir and a fresh copy is downloaded from remote maven repo (where the actual 3rd party jar resides).
Can someone please help on this how can I manage so that maven use my modified jar and does not replace it with old jar during build process.
I am using maven-3.2.5.
you can run maven offline by running with the "-o" argument.
Example:
mvn clean install -o
Keep in mind that this will affect all your other dependencies and your need to have all the dependencies in your local .m2 repository.
Here is another thread taking up the issue of running maven offline:
How do I configure Maven for offline development?
I have created maven based web application so after created application i am getting two errors in pom.xml which are
1.Multiple annotations found at this line:
- Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted
until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (http://
repo.maven.apache.org/maven2): null to http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
2.Multiple annotations found at this line:
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (execution: default-testCompile, phase: test-compile)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (execution: default-compile, phase: compile)
- CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for
org.apache.maven.plugins:maven-compiler-plugin:jar:3.1: ArtifactResolutionException: Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:3.1
Could you please let me know what needs to be done for resolving the issue
If you are facing the same issue I described in my comment above then it seems I could fix it by running mvn eclipse:eclipse with working directory set to Eclipse project folder i.e.
$ cd /path/to/eclipse/workspace/Project
$ mvn eclipse:eclipse
Does this work for you ? Maybe your environment is different . Providing more details might help others to understand your problem even better so as to offer useful suggestions .
I had similar problem Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (execution: default-testCompile, phase: test-compile).
To Fix (apart from installing M2E plug-in and all):
Ensure installed maven is > 3.1 (using mvn -v). If not, you need to upgrade.
Ensure eclipse is pointing to correct maven location (Window->Preferences->Maven->Installations)
On Command prompt, go to project home directory and run mvn eclipse:clean and mvn eclipse:eclipse
Disable and enable Maven nature in eclipse (Right click on project, goto Maven -> Disable Maven Nature. To enable, Right click on project goto Configure -> Convert to Maven Project)
I'm trying to 'release' my project using the gradle release-plugin
The plugin starts by checking if my working copy is clean, so that only properly versioned stuff gets released.
This works just fine on my local machine. But when I try the same thing in a Jenkins job, the build fails complaining various stuff is changed in the workplace. I decided that a lot of stuff was just internally used by jenkins and added it to gitignore:
caches/
native/
wrapper/
But it also considers gradlew as changed:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':checkCommitNeeded'.
> You have uncommitted files:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
M gradlew
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Why does Jenkins change that file how do I prevent that?
I think the following settings on the Jenkins job might be relevant:
Checkout/merge to local branch (optional) is set to master. Without this setting the release plugin complains about not being on a branch
Clean after checkout is currently checked, but checking/unchecking it didn't make a difference
Make gradlew executable is checked, and at least to me sounds like a likely cause, but unchecking it makes the build faile because gradlew is not executable
Pretty old question, but for the record to anyone coming over here, jenkins isn't at fault here, you should commit gradlew with executable bit set:
# git update-index --chmod=+x gradlew
# git commit
Then you will no longer need the jenkins setting to set it executable, which is the workaround causing your issue.