parsiya / parsiya.net

Source for my personal website
https://parsiya.net
11 stars 8 forks source link

Lessons Learned Java Extension development #7

Open parsiya opened 4 years ago

parsiya commented 4 years ago
parsiya commented 4 years ago

Buildship would stop generating the .classpath file from the build.gradle file if there was an error. Gradle would build the jar file correctly but vscode-java could not see the dependencies and give us code completion.

In this case in Bug-Diaries I had this

sourceSets {
    main {
        java {
            srcDir 'src'
        }
        resources {
            srcDir 'src/resources'
        }
    }
}

This gives an error because src/resources is already nested under src. Buildship would stop. This is because the traditional Gradle project structure is:

In the case of bug-diaries, I have everything in src.

Solution

  1. Use the typical Gradle project structure. NAH.
  2. Exclude the resources directory under sourceSets.
sourceSets {
    main {
        java {
            srcDir 'src'
            exclude 'resources/'
        }
        resources {
            srcDir 'src/resources'
        }
    }
}

Solution reference: https://bugs.eclipse.org/bugs/show_bug.cgi?id=504012

  1. Manually add dependency jar files to .classpath.
<classpathentry kind="lib" path="path/to/jar"/>

Write the whole journey because the next person your future self might have the same issue.

While writing down what happened, mention that doing exclude 'resources' will not work, There will be a buildship error that says you need to do resources/ to fully exclude everything inside.