My goal:
- I want to convert an API test framework X code (a maven project) into a jar
which can be used inside another API test framework Y
- This jar
will be deployed to Nexus
- I wanted the test & main classes of framework X in one jar
From SO, I learned that you cannot combine them into one jar
, so you have to have them in separate Jars.
I modified the POM accordingly.
I get a compilation error when I use this command:
mvn clean install -DskipTests
Error snippet:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/main/projectX/src/main/java/com/myapp/core/EnumUserClass.java:[8,46] package com.myapp.testutils.ClassWithEnum does not exist
[ERROR] /C:/main/projectX/src/main/java/com/myapp/core/EnumUserClass.java:[226,6] cannot find symbol
symbol: class EnumUserClass
location: class com.myapp.core.EnumUserClass...etc.
Maven compiler has no problem in finding classes, but it has a problem when finding this enum.
Can someone please tell me how I can resolve this error properly? Am I achieving "my goal" in the correct way?
The example project
(projectX) given in this question is a short version of my actual project
.
The maven command works fine for the example project
, but not for the actual project
.
Example Project Structure: (simplified)
projectX:
src/test/Java
com.myapp.testutils
class ClassWithEnum - This contains a public enum MyEnum
src/test/resources
text files here
src/main/Java
com.myapp.core
class EnumUserClass - This is jackson annotated & uses MyEnum
Example Project pom.xml: (shortened)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp</groupId>
<artifactId>my-jar</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<name>myjar</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!--Many dependencies here-->
</dependencies>
<distributionManagement>
<site>
<id>My-Nexus-Site</id>
<url>https://host.com/path1</url>
</site>
<repository>
<id>My-Nexus-Releases</id>
<name>My-Nexus-Releases</name>
<url>https://host.com/path2</url>
</repository>
<snapshotRepository>
<id>My-Nexus-Snapshots</id>
<name>My-Nexus-Snapshots</name>
<url>https://host.com/path3</url>
</snapshotRepository>
</distributionManagement>
</project>