Maven release plugin fails for cross module dependencies - maven

I have a multi module maven project, like this:
parent
moduleA
moduleB
moduleC
All the modules inherit their version from the parent pom. moduleC has a dependency to moduleB, so the pom.xml for moduleC contains:
<dependency>
<groupId>blah</groupId>
<artifactId>moduleB</artifactId>
<version>${project.version}</version>
</dependency>
This is all fine. I can run the install goal without any problem, and the dependencies resolve fine.
However, I'm trying to do a release using the maven release plugin using the following command:
mvn release:prepare -DreleaseVersion=1.0 -DdevelopmentVersion=1.1-SNAPSHOT
I can see that all the versions in my pom are updated correctly. However, the problem arises when it tries to compile the code. Because release:prepare does not call the install goal, the compilation for moduleC fails because it cannot resolve the dependency to moduleB version 1.0.
Has anybody else come across this problem? I think having cross module dependencies is fine, but the maven release plugin doesn't seem to cater for this?
Thanks in advance

Related

run a unit test in intellij idea without compiling dependency module

I have a project of intellij idea of two module:
project
moduleA
moduleB
and the moduleB is depending on the moduleA.
So right now I have developed some features on moduleA which is used in moduleB. And I have made a release version of moduleA to the nexus maven repo.
Now I am testing on module B.
I do a mvn dependency:resolve -U to update the dependency of module B and reload the project.
I want to only run one unit test in moduleB, which in my opinion, doesn't need to recompile the moduleA since it is already downloaded from the nexus to my local maven repo. But in intellij, it's still compiling the moduleA which takes much time.
How can I avoid compiling a module in project which is already present in maven repo pls?
thank you

How to force modules recompilation in multimodule SpringBoot maven project?

There is a Maven project with two modules with this structure.
project
moduleA
pom.xml // library
moduleB
pom.xml // SpringBoot application
pom.xml // parent aggregator
Module B depends on A.
When executing command mvn spring-boot:run -pl moduleB (from project folder) Maven takes compiled package moduleA.jar from local repository and fails if it is absent there.
Please, help me to find a way of forcing usage of the latest compiled moduleA version every time the moduleB application starts.
In perfect case I would like to avoid mvn install step, just inducing mvn compile (if code changed) or reusing a compiled moduleA; but it also works if somehow application could be started with the latest compiled version of all code in the multimodular project.

Maven compile fails, Maven install succeeds

I am at a loss to explain why I have a Maven compile fails and a Maven install succeeds on the same project. Context: running Eclipse and m2e, everything compiles in the workspace. Run configurations > Maven compile fails (symbol not found) but Maven install succeeds. So, my understanding is that Maven install invokes a Maven compile. The Maven compile fail: symbol not found is on a .java test class's ancestor class. Interestingly, doing a run as > JUnit test on the class shows a compile failure ClassNotFound on the same ancestor class. Can you help?
- Chuck
In eclipse all java files are compiled from source folders to target/classes (it can be changed). Eclipse uses to compile all classes - from pom with all scopes (compile, test, provided etc.) and other projects (check if your project depends on other open in workspace).
When you run maven install - maven checks if all classes have been compiled and create jar package. It does not know how the classes have been compiled? By maven or by eclipse?
If you compile by maven compile (install package) - maven uses only libraries with scope compile/provided. It does not use any other dependencies.
You can make a test. Add to your pom:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
Now use in one of your class from src/main/java #Test annotation. In eclipse project will compile. But when you run mvn clean install the compilation error will be displayed (No such class Test).

IntelliJ - How to link modules for maven goal

I have successfully imported a parent pom with child modules into IntelliJ. The child modules have dependencies between themselves and IntelliJ has correctly set up the classpaths so that changes to module A are reflected in module B. However these dependencies are not maintained when I execute a maven goal in IntelliJ (compile, jetty:run etc). Here is my structure:
client_libs
-- servlet-filter
-- filter-example
filter-example depends on servlet-filter. However when I run maven compile on filter-example I get:
The POM for com.cloudseal.client:servlet-filter:jar:1.0-SNAPSHOT is missing, no dependency information available
I can work around this by manually installing servlet-filter into my local repo before I execute a maven goal but obviously this is not ideal. How can I get IntelliJ to maintain the relationships between the modules when I execute a maven goal?
You shall be able to just run mvn package but from place/path where your parent pom is.
If this's not working for you, please post your pom.xml files.

Maven dependency resolution in a project with modules

my maven project is stuctured as:
project
moduleA
moduleB
moduleC
The moduleB and moduleC are dependend on moduleA. if I execute the 'mvn install' command maven installs moduleA and moduleB in my local repository after that maven tries to install the modeleC but without success, first it tries to find the artifact moduleA in all known maven remote repositories and after that, I'm getting a message that the moduleA artefact is missing. Its so weard because sometimes it works fine and sometimes not. Because of this issue I wasted a lot of time.
The artifact moduleA and moduleB are in my local repository.
I'm using maven 2.2.1 on a 64Bit machine under windows 7 pro.
Does anyone know what the problem is?
Thanks,
Kevin
If you use mvn install, that command will put the artifact in your local repository. Usually in your home directory under .m2/repository unless you have specified differently. If moduleC is trying build (with mvn install) and depends on moduleA, moduleA should be pulling from your local repository when moduleC. If moduleC is looking remotely for moduleA then moduleA never got installed into your local repository.
Check the pom file for moduleC. Make sure the dependency information in moduleC's pom.xml for moduleA matches the groupId, artifactId, and version specified in moduleA's pom.xml. If that matches, make sure moduleA is really producing an artifact. It should be in the target directory under moduleA. If moduleA is not a jar make sure you have the type attribute listed in the pom.xml for moduleA and that moduleC's pom.xml has that type listed for the dependency.
If the above doesn't lead to a consistent resolution, you're may want to edit your question adding some of the pom.xml details.

Resources