Skip to content

Commit

Permalink
Add eclipse workaround for annotation processors (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Nov 8, 2024
1 parent 9234ce8 commit c2f5e86
Showing 1 changed file with 19 additions and 0 deletions.
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

0 comments on commit c2f5e86

Please sign in to comment.