I've created a multi module Maven project in Intellij. The structure is the following
parent
|-module1
|
|-module2
|
|-module3
First I tried to build the parent module, everything was fine. But then I added a class in module2 and used it in module1. So I added a dependency in module1 pom.xml
<dependency>
<groupId>org.example</groupId>
<artifactId>module2</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
But when I try to build the parent (or the module1 as well)- I get the following
[INFO] Building 2 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.example:module2:jar:1.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.188 s
[INFO] Finished at: 2021-12-02T23:29:35+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project module1: Could not resolve dependencies for project org.example:module1:jar:1.0-SNAPSHOT: Could not find artifact org.example:module2:jar:1.0-SNAPSHOT -> [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.
As I understand it tries to download the dependency from the central maven repository. I don't have any repository con1figurations at all.
I am running out of ideas what else to try.
Can you help to fix it?
This is most likely the ordering of your module builds - as specified in the parent POM. Module1 requires a class from module2, and that module (module2) is not yet built. Try swapping the ordering of module1 and module2 in the parent POM so that module2 is built before module1.
Related
I want to make a release with the maven release plugin in two steps:
1. mvn clean release:prepare
2. mvn release:perform
It worked fine the last two releases, but after changing my IDE from intellij to eclipse I am not able to perform a release this way with apache-maven 3.5.3 and eGit 4.9.2.
The general structure of my project is:
parent-dir
-> pom.xml
-> child1-dir
-> pom.xml
-> child2-dir
-> pom.xml
child1 and child2 contain code and packaging to jar, the parent has packaging goal pom.
Configuration of maven-release-plugin in parent pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
The plugin updates all poms with correct version #, committs changes and pushes to the remote repository for both child modules. But for the parent module I get the following error at the end of the log:
[INFO] Reactor Summary:
[INFO]
[INFO] test Parent 0.12-SNAPSHOT ........................ FAILURE [02:46 min]
[INFO] test Child1 ...................................... SUCCESS [ 0.011 s]
[INFO] test Child2 0.12-SNAPSHOT ........................ SUCCESS [ 0.205 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:48 min
[INFO] Finished at: 2018-09-08T12:56:06+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project test-parent: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] git#github.com: Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR]
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.
[ERROR] -> [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/MojoFailureException
I do not understand why I get this error message after succesfull commiting and pushing the children modules?
You need to add your public key in Github.
For help please refer https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
I have successfully installed a JAR into the Maven local repository. I edit my pom.xml to include these lines:
<dependency>
<groupId>org.jcrontab</groupId>
<artifactId>jcrontab</artifactId>
<version>4.0.0</version>
<scope>system</scope>
<systemPath>[somepath]/jcrontab-4.0.0.jar</systemPath>
</dependency>
But, after installing with install:install-file, I think these lines are redundant. I just use them to install and when I want to "use" the jar, they are useless because the jar is in the local repo.
So I changed them to:
<dependency>
<groupId>org.jcrontab</groupId>
<artifactId>jcrontab</artifactId>
<version>4.0.0</version>
</dependency>
The same form as those dependencies that exist in the remote Maven central repo. But now Eclipse complains about:
missing artifact: org.jcrontab:jcrontab:jar:4.0.0
And in the Maven dependencies library in Java Build path, I see red cross on the jar, saying:
jcrontab-4.0.0.jar - D:\desarrollo\eclipse-jee-mars-x86_64\eclipse\${maven.home}\m2\repository\org\jcrontab\jcrontab\4.0.0 (missing)
Under this dir, I only see:
jcrontab-4.0.0.jar.lastUpdated jcrontab-4.0.0.pom.lastUpdated
And no jar is there. But other dependencies jars in this Eclipse repo are in their places.
As I examine my maven home repo (<maven-installation-dir>/m2/repository), the jar is installed there. But in the repo under Eclipse dir, the jar is missing.
I am confused.
If the installation of external jar generates a JAR under Maven installation repo, why does Eclipse "Maven dependencies" library points to a repo under Eclipse dir? The {$maven.home} directory smells bad to me.
Am I supposed to change the dependencies of local installed jars like what I did?
As suggested, I execute the command of install:install-file, and I get:
C:\Windows\System32>mvn install:install-file -Dfile="D:\desarrollo\Java environment\lib\jcrontab-4.0.0.jar" -DgroupId=org.jcronta
b -DartifactId=jcrontab -Dversion=4.0.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # standalone-pom ---
[INFO] Installing D:\desarrollo\Java environment\lib\jcrontab-4.0.0.jar to D:\desarrollo\Java environment\lib\Maven\apache-maven-3.5.0\bin\..\m2\repository\org\jcrontab\jcrontab\4.0.0\jcrontab-4.0.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.597 s
[INFO] Finished at: 2017-08-03T14:27:48+02:00
[INFO] Final Memory: 6M/114M
[INFO] ------------------------------------------------------------------------
The same form as those dependencies that exist in the remote Maven central repo.
But jcrontab doesn't exist on maven central.
See yourself on maven central: https://search.maven.org/#search|ga|1|jcrontab
So you need to install the jar into your local repository if you want to use it like another dependency. You can do that like that:
mvn install:install-file -Dfile=jcrontab-4.0.0.jar -DgroupId=org.jcrontab -DartifactId=jcrontab -Dversion=4.0.0 -Dpackaging=jar
See also the maven documentation here: https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
I've been happily developing my API in AnypointStudio (Eclipse) 6.2.2 until just now I added a JSON-to-Object transformer to a flow; now when I build mvn clean package -U
I get:
Downloading: https://repository.mulesoft.org/nexus/content/repositories/public/org/mule/extensions/mule-extensions/3.8.3/mule-extensions-3.8.3.pom
[INFO] BUILD FAILURE
[INFO] -----------------------------------------------------------------------
[INFO] Total time: 14.775 s
[INFO] Finished at: 2017-07-19T10:38:10+10:00
[INFO] Final Memory: 25M/644M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project foobar: Could not resolve dependencies for project org.foo:bar:mule:1.0.0-SNAPSHOT: Failed to collect dependencies at org.mule.modules:mule-module-json:jar:3.8.3 -> org.mule.modules:mule-module-validation:jar:3.8.3: Failed to read artifact descriptor for org.mule.modules:mule-module-validation:jar:3.8.3: Could not find artifact org.mule.extensions:mule-extensions:pom:3.8.3 in Central (http://central.maven.org/maven2/) -> [Help 1]
Can anyone suggest what's going wrong? Do I need an EE licence to use JSON-to-Object?
I found the answer to this. My POM was using Mule runtime 3.8.3
<mule.version>3.8.3</mule.version>
However, there is no release of the json module that corresponds to this release. The latest at Mulesoft Releases is 3.8.1:
https://repository.mulesoft.org/nexus/content/repositories/releases/org/mule/modules/mule-module-json/3.8.1/
So, manually changing the version of this dependency in my POM gets around the issue:
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-json</artifactId>
<version>3.8.1</version>
<scope>provided</scope>
</dependency>
(Maven build failure for my service):Maven Install is giving me this error. and also there is no settings.xml file in .m2 folder.
[INFO] Adapter CSI_ORDERTRACK_STATUS Bundle ............... SUCCESS [ 0.581 s]
[INFO] Adapter CSI_ORDERTRACK_STATUS Bundle Dependencies .. SUCCESS [ 0.011 s]
[INFO] Adapter CSI_ORDERTRACK_STATUS Bundle Service ....... FAILURE [01:12 min]
[INFO] Adapter CSI_ORDERTRACK_STATUS SWM Zip .............. SKIPPED
[INFO] Adapter CSI_ORDERTRACK_STATUS SWM Package .......... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
------------------------------------------------------------------------
[ERROR] Failed to execute goal on project CSI_ORDERTRACK_STATUS-service: Could not resolve dependencies for project maf.service:CSI_ORDERTRACK_STATUS-service:jar:200.0.14: Failed to collect dependencies at maf:adapter-ordertrackdb:jar:200.0.14: Failed to read artifact descriptor for maf:adapter-ordertrackdb:jar:200.0.14: Could not transfer artifact maf:adapter-ordertrackdb:pom:200.0.14 from/to central (https://repo.maven.apache.org/maven2): connect timed out -> [Help 1]
[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
200.0.14 dependency Service_pom is given below:
<groupId>maf.service</groupId>
<artifactId>CSI_ORDERTRACK_STATUS-service</artifactId>
<version>200.0.14</version>
<packaging>jar</packaging>
<name>Adapter CSI_ORDERTRACK_STATUS Bundle Service</name>
<dependencies>
<dependency>
<groupId>maf</groupId>
<artifactId>adapter-ordertrackdb</artifactId>
<version>200.0.14</version>
</dependency>
<dependency>
Have you tried running Maven in offline mode?
mvn -o install
By default Maven will try to fetch external dependencies from central.
Try to build af:adapter-ordertrackdb:pom:200.0.14 first (non recursive - mvn -N install), and then try Maven install.
If you could supply the pom's it could be helpful.
Because I want to use ActiveAndroid and ActiveAndroid-Validation I need to use Maven (which I never heard of until yesterday). So I installed maven and then tried to install ActiveAndroid.
I wrote a custom serializer in ActiveAndroid using JodaTime and included a JodaTime jar in the ActiveAndroid libs folder. When I build the project using ant it works perfectly well. Using Maven I first downloaded and installed JodaTime in Maven using mvn clean install from within the JodaTime source folder. Seeing the following lines this was successful:
[INFO] --- maven-install-plugin:2.4:install (default-install) # joda-time ---
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.jar
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/pom.xml to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.pom
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3-javadoc.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3-javadoc.jar
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3-sources.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.603s
[INFO] Finished at: Thu Sep 26 13:00:54 CEST 2013
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------
I then tried to install ActiveAndroid using the same mvn clean install from within the ActiveAndroid source folder. This however, resulted in the following errors:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.095s
[INFO] Finished at: Thu Sep 26 13:01:08 CEST 2013
[INFO] Final Memory: 13M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project activeandroid: Compilation failure: Compilation failure:
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[3,21] package org.joda.time does not exist
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[22,16] cannot find symbol
[ERROR] symbol : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[7,24] cannot find symbol
[ERROR] symbol : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[19,26] cannot find symbol
[ERROR] symbol : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[27,28] cannot find symbol
[ERROR] symbol : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] -> [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/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :activeandroid
Does anybody know how I can solve this? All tips are welcome!
==EDIT==
The pom.xml of ActiveAndroid can be found here. I did not change anything in it.
If your IDE does not complain, it means your IDE could build the project.
Then I assume your IDE does not rely on maven to build. I would recommand a stronger integration between maven and your IE.
You are not supposed to manually add the libs to your classpath (in IDE)
Your POM miss the dependency
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
As you have the android-maven-plugin in your build, you need to supply path to the SDK. For this maven plugin, this is done by adding it as property (android.sdk.path) in the properties section of the POM.
So you'll have something like this:
<properties>
<android.sdk.path>your/path/here</android.sdk.path>
</properties>
For quick solution, you can just add this to the POM's properties section. However, local settings like this usually go to settings.xml file in the conf dir inside your maven installation. This will make this property always present no matter what pom you use. Or, if you skip the activeProfiles part, you'll have to invoke maven with that profile enabled - "mvn -pandroidProfile clean install".
<profiles>
<profile>
<id>androidProfile</id>
<properties>
<android.sdk.path>your/path/here</android.sdk.path>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>androidProfile</activeProfile>
</activeProfiles>