Home > Software engineering >  Why is IntelliJ giving me the name of the package and the name of another package in brackets?
Why is IntelliJ giving me the name of the package and the name of another package in brackets?

Time:09-17

(Side-note: the GameLogic module is not imported anywhere and can be ignored.)

As you can see in the picture under this, the java file of the 'ConsoleApp' labels '[DesktopApp]' next to it, but the DesktopApp module does not. The pom.xml of both the ConsoleApp and the DesktopApp module do not reference eachother, so how come IntelliJ labels the source folder this way?

enter image description here

The ConsoleApp/pom.xml:

<?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">
    <parent>
        <artifactId>TicTacToe</artifactId>
        <groupId>com.example</groupId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>ConsoleApp</artifactId>

    <properties>
        <maven.compiler.source>16</maven.compiler.source>
        <maven.compiler.target>16</maven.compiler.target>
    </properties>

</project>

The DesktopApp/pom.xml:

<?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">
    <parent>
        <artifactId>TicTacToe</artifactId>
        <groupId>com.example</groupId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>DesktopApp</artifactId>
    <properties>
        <maven.compiler.source>16</maven.compiler.source>
        <maven.compiler.target>16</maven.compiler.target>
    </properties>

</project>

The pom.xml (Parent pom.xml):

<?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>com.example</groupId>
    <artifactId>TicTacToe</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0-SNAPSHOT</version>
    <modules>
        <module>GameLogic</module>
        <module>DesktopApp</module>
        <module>ConsoleApp</module>
    </modules>

    <properties>
        <maven.compiler.source>16</maven.compiler.source>
        <maven.compiler.target>16</maven.compiler.target>
    </properties>

</project>

Feel free to ask for more information!

CodePudding user response:

This could be caused by the fact that you marked your Java folder as a module folder instead of a source folder. Go to the Project Structure Settings and remove the module named after the Java folder. Then go to the module console app and mark the Java folder as sources.

  • Related