I have two maven modules, AppManager and myApp. These are in the same directory locally and are not available in the company's online repo as they are for testing purposes. In IntelliJ I have no problem using the fields and methods of AppManager and there are no error messages. I am exporting com.mycompany.appManager in my impl pom file for myApp. However, when I build outside of the IDE, i.e. mvn clean install
, there is an error for the package com.mycompany.appManager
does not exist and then associated errors for unresolved symbols for usage of public fields defined in appManager. How can I resolve this problem? I've tried the exporting and adding a dependency, but these two solutions do not work.
pom.xml:
<moduleVersion>4.0.0</moduleVersion>
<parent>
<groupId>com.myCompany</groupId>
<artifactId>myApp</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.myCompany.myApp</groupId>
<artifactId>com.myCompany.myApp.impl</artifactId>
<packaging>bundle</packaging>
<name>My App Implementation</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
com.myCompany.appmanager
</Export-Package>
<Bundle-Activator>com.mycompany.myapp.impl.component</Bundle-Activator>
</instructions>
</configuration>
</plugin>
</plugin>
</build>
Compilation Error:
[ERROR] /root/Desktop/apps/myapp/impl/src/main/java/com/mycompany/myApp/impl/component.java:[11,49] package com.mycompany.appmanager does not exist
[ERROR] /root/Desktop/apps/myapp/impl/src/main/java/com/mycompany/myApp/impl/component.java:[64,49] cannot find symbol
symbol: variable AppManagerModule
location: class com/mycompany/myApp/impl/component
I try to answer the question as far as I understand it:
If you have two projects A and B and A depends on B, then you have to have to build B first. If you e.g. use mvn clean install
, then B.jar will be put into your local repository. After that, you can build A against it (if you choose the correct version in the pom).
For the sake of completeness, if you have two projects A and B and A depends on B, you also have to be sure that your code in B project exists in compiled jar. Obviously you have to write your packages in src/main/java (and not in src/test/java) if you want them visible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With