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
Related
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.
In my maven based IntelliJ project I have 2 modules - modules A and B.
The pom.xml of module A creates an uber jar (including dependencies which are not accessible by the project) and attaches it as an artifact with classifier "withdeps"
The pom.xml of module B has a dependency on the classified "withdeps" artifact A
When I import the maven modules IntelliJ adds the module's A source code in the dependencies of module B (ignoring the "withdeps" classifier).
Is it possible to force Intellij to add the module A dependency to B as "maven library" instead of the default "project source code/Intellij module"? If not what can I do to resolve the compilation errors in IntelliJ (Ctrl+F9)
Thanks
Open the pom.xml of module B only when creating the intellij project. Then all dependencies will be as maven dependencies.
The downside is that this way you will have to open module A as separate project in another window, then when you change something you will have to do mvn install and refresh project B.
Much better solution would be to install all depencencies into maven repository, described here in maven docs.
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
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.
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.