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 javac plugin #22

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion javac-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ dependencies {
}

tasks.compileTestJava {
classpath += rootProject.tasks["shadowJar"].outputs.files
classpath += project(":java-api").tasks.getByName("testJar").outputs.files +
files(rootProject.sourceSets.map { it.compileClasspath }.flatten())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second part could be rootProject.tasks["jar"]outputs.files I think

Copy link
Contributor

@wagyourtail wagyourtail Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I would've passed the api jar as a flag, instead of directly putting it on the classpath. like I do in the other testing subproject

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah the second one is a good idea


javaCompiler = javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(17))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
import java.nio.file.StandardCopyOption;
import java.util.*;

@SuppressWarnings("UrlHashCode")
public class JvmdgJavacPlugin implements Plugin, Closeable {
private BasicJavacTask task;
private Flags flags;
private final Set<URL> classpathURLs = new HashSet<>();

@Override
public String getName() {
Expand Down Expand Up @@ -70,6 +68,7 @@ public void close() throws IOException {
runDowngrade();
}

@SuppressWarnings("UrlHashCode")
private void runDowngrade() throws IOException {
final JavaFileManager fileManager = task.getContext().get(JavaFileManager.class);

Expand All @@ -80,11 +79,11 @@ private void runDowngrade() throws IOException {
).toUri()
).getParentFile();

// must be mutable, since GradleStandardJavaFileManager calls remove
Set<JavaFileObject.Kind> kindSet = new HashSet<>();
kindSet.add(JavaFileObject.Kind.CLASS);
Set<URL> classpathURLs = new HashSet<>();

for(JavaFileObject jfo : fileManager.list(StandardLocation.CLASS_PATH, "", kindSet, true)) {
// the set argument must be mutable, since GradleStandardJavaFileManager calls remove
for(JavaFileObject jfo : fileManager.list(StandardLocation.CLASS_PATH, "",
new HashSet<>(Collections.singletonList(JavaFileObject.Kind.CLASS)), true)) {
classpathURLs.add(jfo.toUri().toURL());
}

Expand Down