0

I need to use base code from a different project. The project folders are laid out as this:

 cs4500-sinanspd-maxlever
 |
  ------ 2
 |
  ------ 3

so 2 & 3 are subdirectories under the main folder and they are 2 SEPARATE projects. I successfully linked module 2 to module 3 in IntelliJ.

enter image description here

And I can use it. IntelliJ finds all the classes in the source folder

enter image description here

However when I try to compile the project 3 I get the following ERROR:

  java: package schema does not exist

Now I did some research but the solutions I found did not work:

Maven compile: package does not exist

Maven: best way of linking custom external JAR to my project?

I can not use mvn install:install-file because this is a module rather than a jar

The pom file for project 3:

<?xml version="1.0" encoding="UTF-8"?>
<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>3</groupId>
<artifactId>3</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>2</groupId>
        <artifactId>2</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
 </project>

and the iml file shows the library path set successfully :

<?xml version="1.0" encoding="UTF-8"?>
<module    org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true"   type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit- compiler-output="false">
    <output url="file://$MODULE_DIR$/target/classes" />
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
  <excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
  <library>
    <CLASSES>
      <root url="file://$MODULE_DIR$/../2" />
    </CLASSES>
    <JAVADOC />
    <SOURCES>
      <root url="file://$MODULE_DIR$/../2/src/main/java" />
    </SOURCES>
  </library>
</orderEntry>
<orderEntry type="library" name="Maven: 2:2:1.0-SNAPSHOT" level="project" />
 </component>
</module>

Any help is appreciated. If any other document/information is needed, please drop a comment

Community
  • 1
  • 1
sinanspd
  • 2,589
  • 3
  • 19
  • 37

1 Answers1

1

For those who have similar issues, The solution for me was to extract both projects into executable jars and link them in parallel using

mvn install:install-file

before compiling the projects. Also specified both jars in the pom file under dependencies.

After this if you try to compile the projects maven puts everything in order for you

sinanspd
  • 2,589
  • 3
  • 19
  • 37