Maven provides a way to show a list of all resolved dependencies with mvn dependency:list:
[INFO] The following files have been resolved:
[INFO] org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] org.hibernate:hibernate-core:jar:5.2.3.Final:compile
[INFO] javax.inject:javax.inject:jar:1:compile
[INFO] javax.annotation:jsr250-api:jar:1.0:compile
[INFO] org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] com.fasterxml:classmate:jar:1.3.0:compile
[INFO] org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:com:compile
[INFO] javax.el:el-api:jar:2.2:compile
[INFO] org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
Gradle's dependency report is in a tree structure, which makes it difficult to clearly see version is finally used.
Is there a command or something that gives me this list of the resolved dependencies without the tree structure?
If you execute the followin at the command line (in your gradle project dir)
gradle tasks
You'll see the following in the list
Help tasks
----------
dependencies - Displays all dependencies declared in root project 'xyz'.
dependencyInsight - Displays the insight into a specific dependency in root project 'xyz'
More info here
Related
In my opinion, we can get the dependency tree by analyzing the pom.xml files recursively without the binary files of these dependencies. However, I find that maven sometimes will download some binary files when I run mvn dependency:tree. Why are these files downloaded?
Might be because maven dependency plugin has its own dependencies:
> [INFO]
> org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
> [INFO] +-
> org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile
> [INFO] | \- commons-validator:commons-validator:jar:1.2.0:compile
> [INFO] | \- commons-digester:commons-digester:jar:1.6:compile
> [INFO] | \-
> (commons-collections:commons-collections:jar:2.1:compile - omitted for
> conflict with 2.0)
More detail is in maven-dependency-plugin
I am having a problem regarding aggregating the data of a multi-module maven project in a single store directory using -Djqassistant.useExecutionRootAsProjectRoot=true.
Here is how my project is structured
root-project [NO PARENT]
----/project-A [PARENT company-parent-pom-A]
----/project-B [PARENT company-parent-pom-B]
I am running the following on the root project
mvn clean install -DskipTests=true com.buschmais.jqassistant:jqassistant-maven-plugin:1.2.0:scan -Djqassistant.useExecutionRootAsProjectRoot=true
But it shows following error.
Failed to execute goal com.buschmais.jqassistant:jqassistant-maven-plugin:1.2.0:scan (default-cli) on project root-project: Cannot re-use store instance from reactor. Either declare the plugin as extension or execute Maven using the property -Djqassistant.store.lifecycle=MODULE on the command line.
So I add -Djqassistant.store.lifecycle=MODULE and run the following
mvn clean install -DskipTests=true com.buschmais.jqassistant:jqassistant-maven-plugin:1.2.0:scan -Djqassistant.useExecutionRootAsProjectRoot=true -Djqassistant.store.lifecycle=MODULE
Now the build succeeds. But while scanning the root-project in the end the plugin resets the store directory. So all the data collected before gets removed. Is this an issue of jqa-maven-plugin or am I doing something wrong?
19984 [INFO] --- jqassistant-maven-plugin:1.2.0:scan (default-cli) # project-B ---
22034 [INFO] Loaded jQAssistant plugins [Common, Core Analysis, JUnit, Java, Maven 3, XML].
22082 [INFO] Opening store in directory '/home/mehedi/Develop/WorkSpace/jqa-projects/test-project/target/jqassistant/store'.
24227 [INFO] Resetting store.
27464 [INFO] Reset finished.
28887 [INFO] Entering /home/mehedi/Develop/WorkSpace/jqa-projects/test-project/project-B/target/classes
29861 [INFO] Leaving /home/mehedi/Develop/WorkSpace/jqa-projects/test-project/project-B/target/classes (183 entries, 972 ms)
29864 [INFO] Entering /home/mehedi/Develop/WorkSpace/jqa-projects/test-project/project-B/target/test-classes
29874 [INFO] Leaving /home/mehedi/Develop/WorkSpace/jqa-projects/test-project/project-B/target/test-classes (12 entries, 10 ms)
30823 [INFO] Closing store in directory '/home/mehedi/Develop/WorkSpace/jqa-projects/test-project/target/jqassistant/store'.
...
124415 [INFO] --- jqassistant-maven-plugin:1.2.0:scan (default-cli) # project-A ---
124423 [INFO] Opening store in directory '/home/mehedi/Develop/WorkSpace/jqa-projects/test-project/target/jqassistant/store'.
124971 [INFO] Entering /home/mehedi/Develop/WorkSpace/jqa-projects/test-project/project-A/target/classes
124973 [INFO] Leaving /home/mehedi/Develop/WorkSpace/jqa-projects/test-project/project-A/target/classes (2 entries, 1 ms)
125222 [INFO] Closing store in directory '/home/mehedi/Develop/WorkSpace/jqa-projects/test-project/target/jqassistant/store'.
...
138156 [INFO] --- jqassistant-maven-plugin:1.2.0:scan (default-cli) # root-project ---
139411 [INFO] Loaded jQAssistant plugins [Common, Core Analysis, JUnit, Java, Maven 3, XML].
139448 [INFO] Opening store in directory '/home/mehedi/Develop/WorkSpace/jqa-projects/test-project/target/jqassistant/store'.
140780 [INFO] Resetting store.
146562 [INFO] Reset finished.
147842 [INFO] Closing store in directory '/home/mehedi/Develop/WorkSpace/jqa-projects/test-project/target/jqassistant/store'.
The setup you're describing should be working so likely you found a bug. Can you report this please on https://github.com/buschmais/jqa-maven-plugin?
I'm trying to compile and run some basic Java code in this repository:
https://github.com/jasebell/mlbookexamples
As an example, inside the Java folder, chapter2.BritneyDilemma.
I'm trying to do this with maven (as there's a pom.xml) but I feel that there's a few things holding me back. I don't know much about Maven; my background is C and cmake. At first glance, I can see why people hate Maven. The pom.xml for the project doesn't seem fully configured / appears quite non-standard:
It only pulls down some dependencies, for example BritneyDilemma requires classifier4J but this isn't mentioned in the pom.xml.
When I do any of the simple commands mvn install/compile etc, the output into target is basically nothing (it's an almost empty jar).
I've tried various approaches such as:
Modifying the pom.xml to add in the maven assembly plugin and running a mvn clean compile package. At most I managed to get a jar that packaged the pom.xml dependencies, but still couldn't compile BritneyDilemma due to not having classifier4j (this isn't mentioned in the pom.xml so I'm unsure how maven is supposed to know it's a requirement/where to pull it from).
Moving away from maven, downloading classifer4j and compiling via the command line. Run time error and a bit of sleuthing pointed out I was missing some classifier4j dependency, I assume this was because I moved away from maven and this would otherwise have been taken care of by some recursive building.
Here is a stock build attempt, making no modifications/taking the pom.xml as is:
~/projects/mlbookexamples/java (master) $ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building mlbook
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/alex/projects/mlbookexamples/java/src/main/resources
Downloading: http://repo.springsource.org/libs-milestone//javax/batch/javax.batch-api/1.0/javax.batch-api-1.0.jar
34K downloaded (javax.batch-api-1.0.jar)
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/alex/projects/mlbookexamples/java/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] Surefire report directory: /home/alex/projects/mlbookexamples/java/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar {execution: default-jar}]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /home/alex/projects/mlbookexamples/java/target/mlbookexamples-1.0-SNAPSHOT.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing /home/alex/projects/mlbookexamples/java/target/mlbookexamples-1.0-SNAPSHOT.jar to /home/alex/.m2/repository/com/datasentiment/mlbook/mlbookexamples/1.0-SNAPSHOT/mlbookexamples-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Wed Mar 04 08:38:56 NZDT 2015
[INFO] Final Memory: 33M/249M
[INFO] ------------------------------------------------------------------------
~/projects/mlbookexamples/java/target (master) $ java -jar mlbookexamples-1.0-SNAPSHOT.jar
no main manifest attribute, in mlbookexamples-1.0-SNAPSHOT.jar
I'm running arch linux.
To compile Chapter 2 it appears there's no requirement to grab the dependencies listed in the pom.xml.
You can simply compile BritneyDilemma from the chapter2 folder (remembering to include the Classifier4J dependency downloaded from
http://sourceforge.net/projects/classifier4j/files/ , this can be kept in the chapter2 folder).
~/projects/mlbookexamples/java/src/chapter2 (master) $ javac -cp Classifier4J-0.6.jar BritneyDilemma.java
You can then go to the src folder and run the class, again with a reference to the classifier4j jar inside the chapter2 folder.
~/projects/mlbookexamples/java/src (master) $ java -classpath .:chapter2/Classifier4J-0.6.jar chapter2.BritneyDilemma
brittany spears = 0.7071067811865475
brittney spears = 0.7071067811865475
britany spears = 0.7071067811865475
britny spears = 0.7071067811865475
briteny spears = 0.7071067811865475
britteny spears = 0.7071067811865475
briney spears = 0.7071067811865475
brittny spears = 0.7071067811865475
brintey spears = 0.7071067811865475
britanny spears = 0.7071067811865475
britiny spears = 0.7071067811865475
britnet spears = 0.7071067811865475
britiney spears = 0.7071067811865475
christina aguilera = 0.0
britney spears = 0.9999999999999998
You will likely already have the required logging library, but it can be grabbed through a package manager as libcommons-logging-java.
Alternatively it is much easier to use eclipse in general. Simply create a new Java project but change the working directory from the default to the java directory inside the repository. Create a new folder 'lib' here and put in the classifier4j jar. In eclipse, right click on classifier4j and 'add to build path'. You can now simply click BritneyDilemma or any other source (adding dependencies to lib and adding to build path when necessary), and run as required.
Happy machine learning.
I have a Jenkins+Nexus installation, and some project there that are automated.
Jenkins deploy the sources and javadocs to nexus in the deploy phase (I am using Maven Release) -- Javadoc could be ok but I don't want to have any sources in Nexus.
I was searching and googling and I don't know how to skip this step.
Thanks a lot
Output from jenkins
[INFO] [INFO]
[INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) # projectA ---
[INFO] [INFO] Installing /var/lib/jenkins/jobs/MyBuild/workspace/target/checkout/MyProject/projectA/target/projectA-1227.jar to .../projectA-1227.jar
[INFO] [INFO] Installing /var/lib/jenkins/jobs/MyBuild/workspace/target/checkout/MyProject/projectA/pom.xml to .../projectA-1227.pom
[INFO] [INFO] Installing /var/lib/jenkins/jobs/MyBuild/workspace/target/checkout/MyProject/projectA/target/projectA-1227-sources.jar to .../projectA-1227-sources.jar
[INFO] [INFO] Installing /var/lib/jenkins/jobs/MyBuild/workspace/target/checkout/MyProject/projectA/target/projectA-1227-javadoc.jar to .../projectA-1227-javadoc.jar
[INFO] [INFO]
Try adding : -Darguments="-Dsource.skip=true -Dmaven.javadoc.skip=true"
to your maven release plugin config (Jenkins > your build configuration > Maven release build > Release goals and options
By default this actually does not happen automatically. Most likely you have configured a release profile somewhere in your pom hierarchy that adds the Maven Source Plugin execution.
You could remove that if you never want to use it or otherwise change the release plugin config to use a different profile or skip source creation or invoke the build with parameters to skip as Guilame has answered
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.