all:
in my project ,I executed this maven command to analyze it's dependency
mvn dependency:analyze
it shows me the following message:
[INFO] --- maven-dependency-plugin:2.1:analyze (default-cli) # console ---
[WARNING] Used undeclared dependencies found:
[WARNING] org.apache.httpcomponents:httpclient:jar:4.3.3:compile
[WARNING] org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[WARNING] commons-lang:commons-lang:jar:2.6:compile
[WARNING] com.itextpdf:itextpdf:jar:5.5.1:compile
[WARNING] commons-logging:commons-logging:jar:1.0.4:compile
How can I find which file used the specific jar?
commons-logging:commons-logging:jar:1.0.4:compile e.g
What you can do is search for the packages or classes contained within that jar from the Eclipse search in the concerned project
Search>File
Related
I am trying to warm up my Docker + Maven cache before building a Kotlin project.
As suggested by many Maven/Docker threads, my docker file looks like this:
COPY pom.xml .
RUN mvn dependency:go-offline
COPY ./src/ src/
RUN mvn package
The thought is that if I change a file in the ./src directory, I want docker cache to skip maven's lengthy dependency download page.
My problem is that the mvn package command still downloads alot of files.
I tried to use mvn -o package (maven offline flag) to diagnose what dependencies are missing, but it just complains that it cannot download dependencies. But I would have expected that the dependencies would allready be downloaded in the previous step. Here are the errors that I get with the "-o" flag:
Step 8/13 : RUN mvn dependency:go-offline
---> Using cache
---> 0334facb9cc9
Step 9/13 : COPY ./src/ src/
---> Using cache
---> 27149a191017
Step 10/13 : RUN mvn -o package
---> Running in 5183eced32ca
Warning: JAVA_HOME environment variable is not set.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building auth 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # auth ---
[WARNING] The POM for org.apache.maven:maven-core:jar:2.0.6 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-monitor:jar:2.0.6 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-utils:jar:2.0.5 is missing, no dependency information available
[WARNING] The POM for org.apache.maven.shared:maven-filtering:jar:1.1 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-interpolation:jar:1.13 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.882 s
[INFO] Finished at: 2019-07-12T07:02:23+00:00
[INFO] Final Memory: 13M/174M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project auth: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.6, org.apache.maven:maven-project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-artifact-manager:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, org.apache.maven:maven-core:jar:2.0.6, org.apache.maven:maven-artifact:jar:2.0.6, org.apache.maven:maven-settings:jar:2.0.6, org.apache.maven:maven-model:jar:2.0.6, org.apache.maven:maven-monitor:jar:2.0.6, classworlds:classworlds:jar:1.1-alpha-2, org.codehaus.plexus:plexus-utils:jar:2.0.5, org.apache.maven.shared:maven-filtering:jar:1.1, org.codehaus.plexus:plexus-interpolation:jar:1.13: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven:maven-plugin-api:jar:2.0.6 has not been downloaded from it before. -> [Help 1
Try following mvn commands, it saved me from the maven error.
RUN mvn --batch-mode --errors --strict-checksums --threads 1C \
org.apache.maven.plugins:maven-dependency-plugin:3.0.2:go-offline
RUN mvn --batch-mode --errors --offline package
From what I gathered from various sources go-offline not always handles caching packages in a correct way, leaving some of them outside of the local repository (see pull request on GitHub).
In my case, the standard mvn dependency:go-offline used go-offline 2.8 and returned errors. I then tried running mvn org.apache.maven.plugins:maven-dependency-plugin:3.2.0:go-offline but I still had some issues with different packages.
What worked for me was using a different "go-offline" plugin available at GitHub.
Using
mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies
finally did the job.
When creating a new Vaadin 8.1.0 app named bogus using the archetype vaadin-archetype-application-multimodule, the build fails in IntelliJ 2017.2 when running Maven Projects panel > bogus-ui > Plugins > jetty > jetty:run
I get these error messages on console.
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java -Dmaven.multiModuleProjectDirectory=/Users/basilbourque/IdeaProjects/bogus/bogus-ui "-Dmaven.home=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3" "-Dclassworlds.conf=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf" "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=55637:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.2 org.eclipse.jetty:jetty-maven-plugin:9.3.9.v20160517:run
objc[11304]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java (0x1060bd4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10712c4e0). One of the two will be used. Which one is undefined.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building bogus-ui 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> jetty-maven-plugin:9.3.9.v20160517:run (default-cli) > test-compile # bogus-ui >>>
Downloading: http://maven.vaadin.com/vaadin-addons/com/example/bogus-backend/1.0-SNAPSHOT/maven-metadata.xml
Downloading: http://maven.vaadin.com/vaadin-addons/com/example/bogus-backend/1.0-SNAPSHOT/bogus-backend-1.0-SNAPSHOT.pom
[WARNING] The POM for com.example:bogus-backend:jar:1.0-SNAPSHOT is missing, no dependency information available
Downloading: http://maven.vaadin.com/vaadin-addons/com/example/bogus-backend/1.0-SNAPSHOT/bogus-backend-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.334 s
[INFO] Finished at: 2017-07-30T22:58:18-07:00
[INFO] Final Memory: 11M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project bogus-ui: Could not resolve dependencies for project com.example:bogus-ui:war:1.0-SNAPSHOT: Could not find artifact com.example:bogus-backend:jar:1.0-SNAPSHOT in vaadin-addons (http://maven.vaadin.com/vaadin-addons) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Process finished with exit code 1
Using Java 8 Update 144 on macOS Sierra 10.12.5 with IntelliJ Ultimate edition 2017.2.
The linked Question, Maven: How to use jetty:run in a multi-module Maven project, without needing to install, is not a duplicate of this Question. That one asks about one module (the Web Module) picking up on changes made in other modules and causing a rebuild rather than retrieving built items from local repository. I am asking how to run the app in the first place, long before needing to trigger re-builds.
Lifecycle > install on root/parent module
Maven needs to find dependencies before running.
You need to run 'mvn install' on root (parent) project or on your backend module (and other project that backend depends on).
you need to run mvn clean install command on the the parent project from root directory>
I am starting out with Maven, following a book. I'm using 3.2.1 on Ubuntu. I have run the following commands:
mvn archetype:generate -DgroupId=org.sonatype.mavenbook.ch03 -DartifactId=simple -DpackageName=org.sonatype.mavenbook
mvn install
I then get a beanstalk error. Essentially, I don't have Amazon credentials. I understand the concepts surrounding Maven. What if I don't want to use Amazon services? Is this really necessary?
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.sonatype.mavenbook.ch03:simple:war:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 143, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building simple 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- beanstalk-maven-plugin:0.2.8:expose-security-credentials (expose-security-credentials) # simple ---
[WARNING] FAILURE
java.lang.IllegalArgumentException: Settings for serverId ('aws.amazon.com') not found. See http://beanstalker.ingenieux.com.br/beanstalk-maven-plugin/security.html for more information
You probably used the elasticbeanstalk archetypes. A short reason (as it seems you're just learning Maven) is to edit your pom and remove the <plugin/> sections for br.com.ingenieux groupId.
Hope it helps
For those who care about the little details on why did it fail
Since release 1.3.x (a few weeks ago), we dropped the usage of aws.accessKey and aws.secretKey. The warnings were there for more than two years in fact :)
Reason: Many projects on github were leaking AWS Keys
Instead, set those as environment variables (AWS_ACCESS_KEY_ID) and (AWS_SECRET_ACCESS_KEY) or use encryption - see this doc for an overview
When I try to run the mvn sonar:sonar target maven are unable to run sonar, here is the relevant part of the mvn output:
[INFO] Execute: org.codehaus.sonar:sonar-maven-plugin:3.6:sonar
[WARNING] While downloading javax.xml:jaxrpc:1.1
This artifact has been relocated to javax.xml:jaxrpc-api:1.1.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar
Embedded error: Unable to load the mojo 'org.codehaus.sonar:sonar-maven-plugin:3.6:sonar' in the plugin 'org.codehaus.sonar:sonar-maven-plugin'. A required class is missing: Lorg/apache/maven/shared/dependency/tree/DependencyTreeBuilder;
org.apache.maven.shared.dependency.tree.DependencyTreeBuilder
It seems like maven doesn't download the required dependency for some reason.
I have a local nexus configured that contains the jar, but i get the same result regardless if I have that profile active in my settings.xml or not.
How should I configure maven in order for it to try to download the dependency?
This was resolved by running:
mvn sonar:sonar -U
Apparently there was some corruption in the .m2 directory.
I'm trying to purge the local repository of a project dependency before launching releasing it in order to make sure every dependency required is on the central repository and is downloaded from it.
In the project folder (containing the pom.xml), I launch the following command:
mvn clean dependency:purge-local-repository -DreResolve=false -Dverbose=true
The project's POM is very simple and just have a declared dependency to junit:junit:3.8.1
The command's output give me:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building corelib-api 0.1.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # corelib-api ---
[INFO] Deleting d:\Users\fpaillard\git-repositories\TEST_CORELIB\corelib-api\target
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building corelib-api 0.1.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:purge-local-repository (default-cli) # corelib-api ---
[WARNING] Missing POM for junit:junit:jar:3.8.1
[INFO] Skipping: corelib-api. It cannot be resolved.
[INFO] Nothing to do for project: test:corelib-api:jar:0.1.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.953s
[INFO] Finished at: Mon May 14 11:34:40 CEST 2012
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
When I look in the local repository (path checked with mvn help:effetive-settings), junit JARs nor POMs are still in .m2/repository/junit/junit/3.8.1 folder.
Isn't dependency:purge-local-repository supposed to delete it?
I don't understand the WARNING of the output above. Why is junit:junit:jar:3.8.1 POM missing? It is still present at .m2/repository/junit/junit/3.8.1/junit-3.8.1.pom
Is the problem related to the INFO line Skipping: corelib-api. It cannot be resolved.? corelib-api is the artifact name of the project I ran mvn dependency:purge-local-repository against.
I know this is old, but I had the same issue, and adding -DactTransitively=false to the command line fixed this issue. I'm unable to tell why it helped, but it did...
I hope this helps.
Looking at the documentation, disabling the actTransitively option causes the purge goal to only purge the dependencies that are named directly by your pom.xml. When it is time for the build, Maven automatically pulls not only your direct dependencies, but all of the TRANSITIVE dependencies down into your local repo as well.
When the purge goal is looking for what to delete, if it finds other dependencies in the dependencies' poms, it transverses those dependencies to figure out the entire tree in your local repository that can be purged. To do this, it at least needs the transitive project's pom.xml. If it cannot find it in the local repo, or if it thinks there might be a more recent version to analyze, it will go to the external repositories to find it.
I don't think it actually tries to download full project content before it starts purging. But since it at least pulls down the projects' pom.xml files, it will complain if it can't find one just like it would if it were resolving dependencies for an actual build.
Besides just preventing Maven from accessing external repositories while purging, another practical reason would be if you have two projects that have the same transitive dependency, and you don't want the purge from one to affect the performance of the other (since the latter will have to download any missing dependencies again).
On the other hand, something to carefully consider is that if you do NOT allow the purge to consider all of the transitive dependencies possible, you stand to leave a set of downstream dependencies sitting in your local repository that you would otherwise have wanted to remove.
I could make a case for saying that the output you are getting is either unnecessary or preventable with another flag like "reportInaccessibleDependencies=false". But unless it is killing your build, I wouldn't say it is anything to worry about.