1

I have a maven project in IntelliJ I have marked the generated sources directory as the source by doing Files>Project Structure and marking as source. I've also done it the other way by right clicking on the folder and marking as generated-sources.

I'm still getting errors saying the IntelliJ cannot find things in these folders Cannot resolve symbol 'name_of_folder' when I'm creating a SOAP implementation

Does anyone know how I can fix this issue? From what I can see I have done everything correctly to mark that folder and IntelliJ Should be able to read from there

Tom Withers
  • 1,171
  • 4
  • 16
  • 28
  • 1
    Maybe this will be of some help to you. [SO Question](https://stackoverflow.com/questions/5905896/intellij-inspection-gives-cannot-resolve-symbol-but-still-compiles-code) You may have to re-import the project. `View -> Tool Windows -> Maven Projects, then click on cycle arrows icon` – Sadiq Ali Jul 17 '17 at 11:33
  • See https://confluence.jetbrains.com/display/IDEADEV/Maven+Integration+FAQ#MavenIntegrationFAQ-GeneratedSources – CrazyCoder Jul 17 '17 at 11:38
  • @CrazyCoder My folders are there that's not the issue. When I mark it as source intellij doesn't seem to know about it – Tom Withers Jul 17 '17 at 11:43
  • Please share the [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – CrazyCoder Jul 17 '17 at 11:43
  • @CrazyCoder my explanation is fine, there is nothing else I can say to make it clear.... – Tom Withers Jul 17 '17 at 11:46
  • @SadiqAli I tried this and It hasnt worked – Tom Withers Jul 17 '17 at 11:51
  • You can share a sample so that others can reproduce it and tell you how to fix it. – CrazyCoder Jul 17 '17 at 12:03

3 Answers3

2

uncheck "Create Separate module per source set" in Preferences > Build, Execution, Deployment > Gradle and then rebuild / gradle refresh

Asad Abdin
  • 140
  • 11
0

Fixed this error....

IntelliJ was marking all subdir of my generated-sources/cxf folder as source roots... So a simple highlight of all folders and un-mark as sources fixes the issue.

Tom Withers
  • 1,171
  • 4
  • 16
  • 28
0

I had a similar situation where I had to generate a Java class from the script through the pom.xml file. Even after I could see that the Java class was generated successfully after compiling the package, I mentioned I was not able to import that generated Java class and use it any other class.

Since this took much of my time to resolve the issue and I could not find any proper answers, I'm posting the steps I performed so that it could be a help to anyone in the future with similar issues.

  1. First mark the generated source directory as the source by going to File ->Project Structure -> modules. Click on the Source tab and add your generated folder as source.

  2. Right click on the folder under generated source folder and select mark directory as -> Generated sources root

  3. Use this plugin so that generated class can be imported to any other class.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>3.0.0</version>
  <executions>
    <execution>
      <id>add-java-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>${project.build.directory}/generated-sources/{folderUnderGeneratedSrcFolder} </source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>

Hope this helps!!!!!

flyingfishcattle
  • 1,817
  • 3
  • 14
  • 25
Aksh
  • 1
  • 1