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

Add eclipse workaround for annotation processors #759

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/main/java/edu/wpi/first/gradlerio/wpi/WPIExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
import org.gradle.api.provider.Provider;
import org.gradle.internal.os.OperatingSystem;
import org.gradle.nativeplatform.plugins.NativeComponentPlugin;
import org.gradle.plugins.ide.eclipse.EclipsePlugin;
import org.gradle.plugins.ide.eclipse.model.ClasspathEntry;
import org.gradle.plugins.ide.eclipse.model.EclipseClasspath;
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
import org.gradle.plugins.ide.eclipse.model.SourceFolder;

import edu.wpi.first.gradlerio.wpi.java.WPIJavaExtension;
import edu.wpi.first.gradlerio.wpi.cpp.WPINativeExtension;
Expand Down Expand Up @@ -85,6 +90,20 @@ public WPIExtension(Project project) {

project.getPlugins().withType(JavaPlugin.class, p -> {
java = factory.newInstance(WPIJavaExtension.class, project, sim, versions);

project.getPluginManager().apply(EclipsePlugin.class);
EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
EclipseClasspath eclipseClasspath = eclipse.getClasspath();
eclipseClasspath.containers("org.eclipse.buildship.core.gradleclasspathcontainer");
eclipseClasspath.getFile().whenMerged(cp -> {
if (cp instanceof org.gradle.plugins.ide.eclipse.model.Classpath ecp) {
List<ClasspathEntry> entries = ecp.getEntries();
// TODO make this grab the build folder dynamically, and include everything else necessary
SourceFolder src = new SourceFolder("build/generated/sources/annotationProcessor/java/main", null);
entries.add(src);
}
});

});

maven = factory.newInstance(WPIMavenExtension.class, project);
Expand Down