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

Do not compile reactor annotation processors with the j2cl #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public String toString() {
};
}

protected final static Path annotationProcessorPath = Path.of("META-INF", "services", "javax.annotation.processing.Processor");

public final List<com.vertispan.j2cl.build.Input> inputs = new ArrayList<>();

protected Input input(Dependency dependency, String outputType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
import com.vertispan.j2cl.tools.Javac;

import javax.annotation.Nullable;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -39,7 +35,7 @@ public class BytecodeTask extends TaskFactory {
public static final PathMatcher NOT_BYTECODE = p -> !JAVA_BYTECODE.matches(p);

public static final PathMatcher APT_PROCESSOR = p ->
p.equals(Paths.get("META-INF", "services", "javax.annotation.processing.Processor"));
p.equals(annotationProcessorPath);

@Override
public String getOutputType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.vertispan.j2cl.tools.J2cl;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.Collections;
Expand Down Expand Up @@ -38,8 +39,9 @@ public String getVersion() {
@Override
public Task resolve(Project project, Config config) {
// J2CL is only interested in .java and .native.js files in our own sources
Input ownJavaBytecode = input(project, OutputTypes.BYTECODE);
Input ownJavaSources = input(project, OutputTypes.STRIPPED_SOURCES).filter(JAVA_SOURCES, NATIVE_JS_SOURCES);
List<Input> ownNativeJsSources = Collections.singletonList(input(project, OutputTypes.BYTECODE).filter(NATIVE_JS_SOURCES));
List<Input> ownNativeJsSources = Collections.singletonList(ownJavaBytecode.filter(NATIVE_JS_SOURCES));

// From our classpath, j2cl is only interested in our compile classpath's bytecode
List<Input> classpathHeaders = scope(project.getDependencies().stream()
Expand All @@ -63,6 +65,14 @@ public Task resolve(Project project, Config config) {
)
.collect(Collectors.toUnmodifiableList());

if(ownJavaBytecode.getProject().hasSourcesMapped()) {
for (Path p : ownJavaBytecode.getParentPaths()) {
if(Files.exists(p.resolve(annotationProcessorPath))) {
return;
}
}
}

J2cl j2cl = new J2cl(classpathDirs, bootstrapClasspath, context.outputPath().toFile(), context);

// TODO convention for mapping to original file paths, provide FileInfo out of Inputs instead of Paths,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public Task resolve(Project project, Config config) {
filesToProcess.add(makeFileInfo(path));
}
}

if(inputSources.getProject().hasSourcesMapped()) {
for (Path p : inputSources.getParentPaths()) {
if(Files.exists(p.resolve(annotationProcessorPath))) {
return;
}
}
}

GwtIncompatiblePreprocessor preprocessor = new GwtIncompatiblePreprocessor(context.outputPath().toFile(), context);
preprocessor.preprocess(filesToProcess);
};
Expand Down
Loading