9

There are already many similar questions, but none of the proposed solutions (mainly "Clear caches and restart IntelliJ) solves my problem.

I have a maven project that I imported into IntelliJ Community Edition 2017.1 . My maven build automatically creates some java sources from Google protobuf specifications.

Excerpt from pom.xml

         <plugin>
            <groupId>com.github.os72</groupId>
            <artifactId>protoc-jar-maven-plugin</artifactId>
            <version>3.2.0</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <protocVersion>3.1.0</protocVersion> <!-- 2.4.1, 2.5.0, 2.6.1, 3.1.0 -->
                        <inputDirectories>
                            <include>src/main/protobuf</include>
                        </inputDirectories>
                        <outputDirectory>${project.build.directory}/generated-sources/protobuf</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The folder /generated-sources/protobuf is correctly recognized as "generated-sources" with a blue icon and the wheel for generated sources under IntelliJ -> File -> Project Structure -> Modules -> Sources

The maven target "compile" also works fine.

But the IntelliJ "internal" java compiler complains "Cannot resolve symbol" for my generated class.

Solutions I tired so far

  1. add an intermediate folder /target/generated-sources/protobuf/ => did not help
  2. Invalidate caches, delete project file, reimport, restart IDE => did not help
  3. Maven -> Reimport all projects => did not help

Any more suggestions?

Robert
  • 1,579
  • 1
  • 21
  • 36

4 Answers4

10

In IntelliJ IDEA 2016 and newer you can change this setting in Help > Edit Custom Properties.

On older versions, there's no GUI to do it. But you can change it if you edit the IntelliJ IDEA Platform Properties file as described here: https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties

# Maximum file size (kilobytes) IDE should provide code assistance for.
idea.max.intellisense.filesize=50000

# Maximum file size (kilobytes) IDE is able to open.
idea.max.content.load.filesize=50000

Don't forget to save and restart IntelliJ IDEA.

Johnny
  • 14,397
  • 15
  • 77
  • 118
8

SOLUTION: The generated files were to large. Had to increase

idea.max.intellisense.filesize=2500

in IDE_HOME\bin\idea.properties as described here: File size exceeds configured limit (2560000), code insight features not available

Robert
  • 1,579
  • 1
  • 21
  • 36
1

If the generated file size is not the issue you have; please look @CrazyCoder comment above. In the plugin configuration change the execution phase to process-resources.

<executions>
    <execution>
        <phase>process-resources</phase>
        <goals>
            <goal>compile</goal>
            <goal>compile-custom</goal>
        </goals>
    </execution>
</executions>

      
Srikanth
  • 1,015
  • 12
  • 16
0

Try adding

<goal>compile</goal>
<goal>compile-custom</goal>

to the goals node.

Dan Nuffer
  • 665
  • 1
  • 6
  • 11