Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optional source directory to be added into project classpath #1196

Closed
jdneo opened this issue Aug 11, 2022 · 0 comments · Fixed by #1197
Closed

Allow optional source directory to be added into project classpath #1196

jdneo opened this issue Aug 11, 2022 · 0 comments · Fixed by #1197

Comments

@jdneo
Copy link
Contributor

jdneo commented Aug 11, 2022

Expected Behavior

Allow to add optional source folder classpath entry even the folder does not exist on disk.

Current Behavior

folder that does not exist on disk will be ignored.

Context

Currently, in https://github.com/eclipse/buildship/blob/35d01caad3ab023fdd9fdf4a1b9e9c738bff7fd0/org.eclipse.buildship.core/src/main/java/org/eclipse/buildship/core/internal/workspace/SourceFolderUpdater.java#L138

The source folder entry will be ignored if it does not exist.

There is one exception when the source folder has the optional attribute:

<attribute name="optional" value="true"/>

In JDT, optional classpath entry is allowed to be not existed - if I understood the JDT code correctly:

https://github.com/eclipse-jdt/eclipse.jdt.core/blob/f71a39afb62a1436cd094f6274ad9a91b96484f7/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java#L2219-L2224

Steps to Reproduce

Try to add a non-exist source folder to classpath, sth like:

EclipseModel model = project.getExtensions().findByType(EclipseModel)
model.classpath.file.whenMerged { Classpath cp ->
  SourceFolder entry = new SourceFolder("<a path that does not exist on disk>", null)
  entry.entryAttributes.put("optional", "true")
  entry.entryAttributes.put("ignore_optional_problems", "true")
  cp.entries.add(entry)
}

More information

Another example is m2e, for example, if we import the spring-petclinic as a Maven project, m2e will generate classpath entries like:

<classpathentry kind="src" path="target/generated-sources/annotations">
	<attributes>
		<attribute name="optional" value="true"/>
		<attribute name="maven.pomderived" value="true"/>
		<attribute name="ignore_optional_problems" value="true"/>
		<attribute name="m2e-apt" value="true"/>
	</attributes>
</classpathentry>

while that generated folder does not exist on disk until build.

jdneo added a commit to jdneo/protobuf-gradle-plugin that referenced this issue Aug 11, 2022
- add the generated source folders to Eclipse classpath entries. Due to
  a limition of Buildship, we have to create those folders beforehand,
  see: eclipse-buildship/buildship#1196

Signed-off-by: sheche <[email protected]>
jdneo added a commit to jdneo/eclipse.jdt.ls that referenced this issue Aug 15, 2022
A Gradle init script is added as a patch to automatically add Protobuf
output source directories to clsspath. The script works for Gradle
'com.google.protobuf' plugin 0.8.4 or higher.

As a side effect, the Protobuf output source directories will be created
beforehand, due to an issue of Buildship.
See: eclipse-buildship/buildship#1196.

Signed-off-by: sheche <[email protected]>
jdneo added a commit to jdneo/eclipse.jdt.ls that referenced this issue Aug 16, 2022
A Gradle init script is added as a patch to automatically add Protobuf
output source directories to clsspath. The script works for Gradle
'com.google.protobuf' plugin 0.8.4 or higher.

The init script will be extracted as a sibling file of the bundle jars.

As a side effect, the Protobuf output source directories will be created
beforehand, due to an issue of Buildship.
See: eclipse-buildship/buildship#1196.

Signed-off-by: sheche <[email protected]>
jdneo added a commit to jdneo/eclipse.jdt.ls that referenced this issue Aug 16, 2022
A Gradle init script is added as a patch to automatically add Protobuf
output source directories to clsspath. The script works for Gradle
'com.google.protobuf' plugin 0.8.4 or higher.

The init script will be extracted as a sibling file of the bundle jars.

As a side effect, the Protobuf output source directories will be created
beforehand, due to an issue of Buildship.
See: eclipse-buildship/buildship#1196.

Signed-off-by: sheche <[email protected]>
rougsig pushed a commit to rougsig/protobuf-gradle-plugin that referenced this issue Aug 21, 2022
- add the generated source folders to Eclipse classpath entries. Due to
  a limition of Buildship, we have to create those folders beforehand,
  see: eclipse-buildship/buildship#1196

Signed-off-by: sheche <[email protected]>
jdneo added a commit to jdneo/eclipse.jdt.ls that referenced this issue Aug 22, 2022
A Gradle init script is added as a patch to automatically add Protobuf
output source directories to classpath. The script works for Gradle
'com.google.protobuf' plugin 0.8.4 or higher.

The init script will be extracted to a cache folder.

As a side effect, the Protobuf output source directories will be created
beforehand, due to an issue of Buildship.
See: eclipse-buildship/buildship#1196.

Signed-off-by: sheche <[email protected]>
jdneo added a commit to eclipse-jdtls/eclipse.jdt.ls that referenced this issue Aug 22, 2022
)

A Gradle init script is added as a patch to automatically add Protobuf
output source directories to classpath. The script works for Gradle
'com.google.protobuf' plugin 0.8.4 or higher.

The init script will be extracted to a cache folder.

As a side effect, the Protobuf output source directories will be created
beforehand, due to an issue of Buildship.
See: eclipse-buildship/buildship#1196.

Signed-off-by: sheche <[email protected]>
rougsig pushed a commit to rougsig/protobuf-gradle-plugin that referenced this issue Aug 29, 2022
- add the generated source folders to Eclipse classpath entries. Due to
  a limition of Buildship, we have to create those folders beforehand,
  see: eclipse-buildship/buildship#1196

Signed-off-by: sheche <[email protected]>
rougsig pushed a commit to rougsig/protobuf-gradle-plugin that referenced this issue Aug 29, 2022
- add the generated source folders to Eclipse classpath entries. Due to
  a limition of Buildship, we have to create those folders beforehand,
  see: eclipse-buildship/buildship#1196

Signed-off-by: sheche <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant