Peter Hall
Peter Hall

Reputation: 58735

Intellij Keeps changing location of generated source directory

I have a Maven project, using Antlr 4 to generate some of the sources. The directory structure is like this:

- pom.xml
- src
    +- main
    |   +- antlr4
    |   |   +- mypackage
    |   |       +- MyGrammar.g4
    |   +- java
    |       +- mypackage
    +- target
        +- generated-sources
            +- antlr4
                +- mypackage
                    +- MyGrammarParser.java
                    +-  ... etc

This mostly works. But every now and then Intellij will treat src/target/generated-sources/antlr4/mypackage as the generated sources directory, instead of just src/target/generated-sources/antlr4/, and I have to change it back manually.

Is there a way to fix this so that Intellij doesn't try to change the generated sources directory?

My POM contains:

<build>
    <plugins>
        <plugin>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-maven-plugin</artifactId>
            <version>4.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>antlr4</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <listener>true</listener>
                <visitor>true</visitor>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.antlr</groupId>
        <artifactId>antlr4</artifactId>
        <version>4.5</version>
    </dependency>
</dependencies>

Upvotes: 2

Views: 668

Answers (2)

CrazyCoder
CrazyCoder

Reputation: 401965

IntelliJ IDEA allows to configure how the generated sources folders are detected:

generated

Upvotes: 3

Spasoje Petronijević
Spasoje Petronijević

Reputation: 1598

I had similar problem with TFS version control. I had wrong mappings set in my workspace. Maybe you are experiencing similar problem.

Upvotes: -1

Related Questions