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

Update Eclipse JDT/ECJ #194

Open
wants to merge 4 commits into
base: master
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
name: Verify
uses: takari/takari-gh-actions/.github/workflows/ci.yml@v3
with:
jdk-matrix: '[ 11,17,21 ]'
jdk-matrix: '[ 17,21 ]'
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ To use it, declare the plugin as extension in your POM:
<plugin>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>
<extensions>true</extensions>
</plugin>
```

Build time requirement of this project and projects using takari-lifecycle-plugin is Java11 (since 2.0.9),
but the project can produce even Java 7 byte code by using the "release" compiler flag.
Build time requirement of this project and projects using takari-lifecycle-plugin is Java17 (since 2.3.0+),
but the project can produce even Java 8 byte code by using the "release" compiler flag.
19 changes: 15 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>io.takari</groupId>
<artifactId>takari</artifactId>
<version>60</version>
<version>63</version>
</parent>

<groupId>io.takari.maven.plugins</groupId>
Expand All @@ -36,16 +36,27 @@
</scm>

<properties>
<!--
Note: actual runtime requirement is Java 17+ due Eclipse JDT/ECJ!
But, to support Maven 3.6/3.8 that use ancient Eclipse Sisu, we cannot
create components having bytecode newer than Java 14.
So we cheat here: we create components having bytecode Java 11 to make them
discoverable, but takari-lifecycle due dependencies is in fact Java 17+
-->
<takari.javaSourceVersion>11</takari.javaSourceVersion>

<mavenVersion>3.9.9</mavenVersion>
<aetherVersion>1.9.22</aetherVersion>
<sisuVersion>0.9.0.M3</sisuVersion>
<incrementalbuild.version>1.0.3</incrementalbuild.version>
<guava.version>33.3.0-jre</guava.version>
<mavenPluginPluginVersion>3.15.0</mavenPluginPluginVersion>
<mavenPluginPluginVersion>3.15.1</mavenPluginPluginVersion>
<m2eWorkspaceVersion>0.4.0</m2eWorkspaceVersion>
<plexusUtilsVersion>4.0.1</plexusUtilsVersion>
<plexusUtilsVersion>4.0.2</plexusUtilsVersion>
<plexusXmlVersion>3.0.1</plexusXmlVersion>
<pluginTestingVersion>3.0.5</pluginTestingVersion>

<!-- UT and IT only! -->
<guava.version>33.3.1-jre</guava.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.junit.runner.RunWith;

@RunWith(MavenJUnitTestRunner.class)
@MavenVersions({"3.6.3", "3.8.8", "3.9.6"})
@MavenVersions({"3.6.3", "3.8.8", "3.9.9"})
public abstract class AbstractIntegrationTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import static io.takari.maven.testing.TestResources.assertFilesPresent;

import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
import io.takari.maven.testing.executor.MavenExecutionResult;
import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.junit.Assert;
Expand Down Expand Up @@ -106,7 +106,7 @@ private String readZipFileEntryUTF8(File zipFile, String entryPath) throws IOExc
}

private String readFileUTF8(File file) throws IOException {
return Files.toString(file, StandardCharsets.UTF_8);
return Files.readString(file.toPath(), StandardCharsets.UTF_8);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -40,7 +41,7 @@ private Properties filter(MavenExecution verifierBuilder) throws Exception {

Properties properties = new Properties();
InputStream is = new FileInputStream(new File(result.getBasedir(), "target/classes/filtered.properties"));
Reader reader = new InputStreamReader(is, "UTF-8");
Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8);
try {
properties.load(reader);
} finally {
Expand Down
10 changes: 5 additions & 5 deletions takari-lifecycle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-java</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -136,7 +136,7 @@
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.33.0</version>
<version>3.39.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand All @@ -147,7 +147,7 @@
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
<version>3.33.0</version>
<version>3.39.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand All @@ -158,7 +158,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.18.600</version>
<version>3.21.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand Down Expand Up @@ -266,7 +266,7 @@
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.7</version>
<version>9.7.1</version>
<scope>test</scope>
</dependency>
<!-- testing deploy -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public NameEnvironmentAnswer findType(String packageName, String typeName, Acces
if (classFile != null) {
try (InputStream is = Files.newInputStream(classFile)) {
return new NameEnvironmentAnswer(
ClassFileReader.read(is, classFile.getFileName().toString(), false), accessRestriction);
ClassFileReader.read(is, classFile.getFileName().toString()), accessRestriction);
}
}
} catch (ClassFormatException | IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.takari.resources.filtering.ResourcesProcessor;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -70,6 +71,10 @@ public abstract class AbstractProcessResourcesMojo extends TakariLifecycleMojo {
private BuildContext context;

protected void process(List<Resource> resources, File outputDirectory) throws MojoExecutionException {
if (encoding == null) {
getLog().warn("Using platform encoding to process resources, i.e. build is platform dependent!");
}
Charset charset = encoding == null ? Charset.defaultCharset() : Charset.forName(encoding);
for (Resource resource : resources) {
boolean filter = Boolean.parseBoolean(resource.getFiltering());
try {
Expand All @@ -86,7 +91,7 @@ protected void process(List<Resource> resources, File outputDirectory) throws Mo
targetDirectory = outputDirectory;
}
if (filter) {
Map<Object, Object> properties = new HashMap<Object, Object>(this.properties);
Map<Object, Object> properties = new HashMap<>(this.properties);
properties.putAll(sessionProperties); // command line parameters win over project properties
properties.put("project", project);
properties.put(
Expand All @@ -105,7 +110,7 @@ protected void process(List<Resource> resources, File outputDirectory) throws Mo
resource.getExcludes(),
properties,
filters,
encoding,
charset,
missingPropertyAction);
} else {
processor.process(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import io.takari.incrementalbuild.ResourceMetadata;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -51,7 +51,7 @@ public void process(
List<String> excludes,
Map<Object, Object> filterProperties,
List<File> filters,
String encoding,
Charset encoding,
MissingPropertyAction mpa)
throws IOException {
Map<Object, Object> effectiveProperties = new HashMap<>(filterProperties);
Expand Down Expand Up @@ -82,7 +82,7 @@ private void filterResource(
File sourceDirectory,
File targetDirectory,
Map<Object, Object> filterProperties,
String encoding,
Charset encoding,
MissingPropertyAction mpa)
throws IOException {
File outputFile = relativize(sourceDirectory, targetDirectory, input.getResource());
Expand All @@ -102,20 +102,12 @@ public void filter(
mustache.execute(writer, properties).close();
}

private Reader newReader(Resource<File> resource, String encoding) throws IOException {
if (encoding == null) {
return new FileReader(resource.getResource());
} else {
return new InputStreamReader(new FileInputStream(resource.getResource()), encoding);
}
private Reader newReader(Resource<File> resource, Charset encoding) throws IOException {
return new InputStreamReader(new FileInputStream(resource.getResource()), encoding);
}

private Writer newWriter(Output<File> output, String encoding) throws IOException {
if (encoding == null) {
return new OutputStreamWriter(output.newOutputStream());
} else {
return new OutputStreamWriter(output.newOutputStream(), encoding);
}
private Writer newWriter(Output<File> output, Charset encoding) throws IOException {
return new OutputStreamWriter(output.newOutputStream(), encoding);
}

private static class NoEncodingMustacheFactory extends DefaultMustacheFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -45,7 +46,7 @@ public void process(
List<String> includes,
List<String> excludes,
Map<Object, Object> filterProperties,
String encoding,
Charset encoding,
MissingPropertyAction mpa)
throws IOException {
filterProcessor.process(
Expand All @@ -66,7 +67,7 @@ public void process(
List<String> excludes,
Map<Object, Object> filterProperties,
List<File> filters,
String encoding,
Charset encoding,
MissingPropertyAction mpa)
throws IOException {
filterProcessor.process(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeTrue;

import com.google.common.base.Charsets;
import com.google.common.io.Files;
import io.takari.maven.plugins.compile.javac.CompilerJavac;
import io.takari.maven.plugins.compile.jdt.CompilerJdt;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -228,7 +228,8 @@ public void testClasspath_dependencySourceTypes_ignore() throws Exception {
// assert the compiler uses .class file when dependencySourceTypes=ignore

File dependency = compile("compile/basic");
Files.write("corrupted", new File(dependency, "target/classes/basic/Basic.java"), Charsets.UTF_8);
Files.writeString(
new File(dependency, "target/classes/basic/Basic.java").toPath(), "corrupted", StandardCharsets.UTF_8);
touch(new File(dependency, "target/classes/basic/Basic.java")); // javac will pick newer file by default

File basedir = resources.getBasedir("compile/classpath");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static io.takari.maven.testing.TestResources.create;

import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import io.takari.maven.plugins.compile.CompilerBuildContext;
import io.takari.maven.plugins.compile.jdt.classpath.Classpath;
Expand All @@ -14,6 +13,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -45,7 +45,7 @@ public class FilerImplTest {

@Test
public void testGetResource_unsupportedLocation() throws Exception {
EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8);
EclipseFileManager fileManager = new EclipseFileManager(null, StandardCharsets.UTF_8);

FilerImpl filer = new FilerImpl(null /* context */, fileManager, null /* compiler */, null /* env */);

Expand All @@ -59,7 +59,7 @@ public void testGetResource_unsupportedLocation() throws Exception {

@Test
public void testGetResource_location_classpath() throws Exception {
EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8);
EclipseFileManager fileManager = new EclipseFileManager(null, StandardCharsets.UTF_8);

List<File> classpath = new ArrayList<>();
classpath.add(new File("src/test/projects/compile-jdt-proc/getresource-location-classpath/classes"));
Expand All @@ -78,13 +78,13 @@ public void testGetResource_location_classpath() throws Exception {

private static String toString(FileObject file) throws IOException {
try (InputStream is = file.openInputStream()) {
return CharStreams.toString(new InputStreamReader(is, Charsets.UTF_8));
return CharStreams.toString(new InputStreamReader(is, StandardCharsets.UTF_8));
}
}

@Test
public void testRecreateSourceFile() throws Exception {
EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8);
EclipseFileManager fileManager = new EclipseFileManager(null, StandardCharsets.UTF_8);

File outputDir = temp.newFolder();
fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outputDir));
Expand All @@ -105,7 +105,7 @@ public void testRecreateSourceFile() throws Exception {

@Test
public void testRecreateResource() throws Exception {
EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8);
EclipseFileManager fileManager = new EclipseFileManager(null, StandardCharsets.UTF_8);

File outputDir = temp.newFolder();
fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outputDir));
Expand Down Expand Up @@ -149,7 +149,7 @@ public void testBinaryOriginatingElements() throws Exception {
Compiler compiler =
new Compiler(namingEnvironment, errorHandlingPolicy, compilerOptions, requestor, problemFactory);

EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8);
EclipseFileManager fileManager = new EclipseFileManager(null, StandardCharsets.UTF_8);
File outputDir = temp.newFolder();
fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outputDir));

Expand All @@ -167,7 +167,7 @@ public void testBinaryOriginatingElements() throws Exception {

@Test
public void testResourceDoesNotExist() throws Exception {
EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8);
EclipseFileManager fileManager = new EclipseFileManager(null, StandardCharsets.UTF_8);

File outputDir = temp.newFolder();
fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outputDir));
Expand Down
Loading