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).
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.
I'm getting an error - package com.eviware.soapui.tools does not exist, when I try to run my junit test from intellij using a maven command such as "mvn clean verify -Dwebdriver.driver=chrome -Dtags="API" -Dproperties=test.properties"
I'm using intellij and added the the soapui-5.2.1.jar file as a dependency to the project (File->Project Preferences->Modules->Add jar). The code to run is pretty straight forward:
SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
runner.setProjectFile(RESOURCE_FOLDER + "periodictable-
soapui-project.xml");
runner.run();
Do I need to add any dependencies to the pom file to get it to run? At this stage all I have done is the above steps to add the jar and used the import below:
import com.eviware.soapui.tools.SoapUITestCaseRunner;
Thanks.
The import and code itself looks fine but try adding the below dependency to your POM file.
<dependency>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui</artifactId>
<version>X.X.X</version>
<scope>test</scope>
</dependency>
This dependency would download the SOAPUI jar(version of your choice, for me it works with v5.2.1) and allow you to execute the test suites inside your test project XML.
The official documentation says:
Copy all the jar files from the lib folder for SoapUI Pro Installation folder in class file path. Copy the soapui-pro-5.0.0.jar (or corresponding version) from the bin folder in SoapUI Pro intallation [sic] directory.
For the open-source version, the same instructions apply, you just copy the non-Pro resources.
If you already added the soapui-5.2.1.jar as a dependency to your project, you should be able to check that it was brought in with all of its dependencies correctly.
I am a maven newbie. My project depends on another maven project (ProjectA) in that I need to run mvn clean package on ProjectA which gives me JarA.
Then, I need to run java JarA feeding it with an xml configuration file which gives me another JarB. I need both JarA and JarB as dependencies on my project (ProjectB).
Any comments on whether it is possible to achieve these steps in projectB's pom file? Would having parent-submodule type of a configuration help? Thanks!
Maybe. The most simple solution to get JarB would be to add a unit test to project A. But that doesn't tell Maven about this JAR, so it will ignore it.
The next step would be to get the test to write JarB as JarA-config into the target/ folder of project A. Maven supports multiple artifacts as "build results". You can then use the "qualifier" to distinguish between them.
Use build-helper:attach-artifact to tell Maven about the second JAR. See "Attach additional artifacts to your project" for an example.
Note that package happens after test, so your test case can create the second JAR and build-helper will then find it.
In project B, you can then use this to depend on both JARs
<dependency>
<groupId>x</groupId>
<artifactId>jarA</artifactId>
</dependency>
<dependency>
<groupId>x</groupId>
<artifactId>jarA</artifactId>
<classifier>config</classifier>
</dependency>
Note the additional <classifier> element.
Note: For this to work, you need to run mvn install in project A.
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
there
I met a weird problem. I have a multi-modules enterprise project that is built in Maven. I setup the project hierarchy like this
parentPom
--MyEar (packaging ear)
--MyUtilJar (packaging jar)
--MyEJB (packing ejb)
--MyWeb (packaging war)
In the MyEJB project, the pom.xml actually binds the apt plugin to the generate-sources phase to generate some java codes. MyEJB depends on MyUtilJar project.
My problem is that when I execute the mvn clean compile, everything works fine. But if I execute mvn clean generate-sources instead, it throws error, complaining it cannot resolve dependency for artifact mygroup:MyUtilJar:jar:1.0.
How can I solve this issue?
In order for the generate-sources to work, you need to have all dependencies in a repository - your local one or a remote one. Just having the dependency in a folder near where it's needed won't work.
Try building and installing the until to put it in your local repository then running the generate-sources.