Skip to content

Commit

Permalink
refact: reactivate examples
Browse files Browse the repository at this point in the history
Signed-off-by: sebthom <sebthom@users.noreply.github.com>
  • Loading branch information
sebthom authored and vorburger committed Sep 30, 2024
1 parent 24abb73 commit 5b59e61
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package org.lastnpe.examples.hello;

import org.eclipse.jdt.annotation.NonNull;

@SuppressWarnings("unused")
public class GenericsExample {

private static class Parent<T> {
}

// Null constraint mismatch: The type 'T' is not a valid substitute for the type parameter '@NonNull T'
// This seems wrong, because the mouse over hover clearly shows Parent<@NonNull T> (from @NonNullByDefault) and Child<@NonNull T>
// Workaround "Child<@NonNull T>" makes it disappear, but why is this needed?
// TODO Is this https://bugs.eclipse.org/bugs/show_bug.cgi?id=522142 ?
private static class Child<@NonNull T> extends Parent<T> {
private static class Child<T> extends Parent<T> {
}
}
8 changes: 4 additions & 4 deletions examples/maven/jdt-ecj-settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=javax.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
Expand Down Expand Up @@ -57,7 +57,7 @@ org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warnin
org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=error
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
Expand Down Expand Up @@ -95,4 +95,4 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.compiler.source=17
5 changes: 3 additions & 2 deletions examples/maven/jdt-ecj-settings/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<version>3.3.1</version>
<!-- Disable src/test/resources, not needed for creating settings JARs -->
<executions>
<execution>
Expand All @@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<version>3.5.0</version>
<!-- Disable Surefire, not needed for creating settings JARs -->
<executions>
<execution>
Expand All @@ -59,6 +59,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.3</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down
99 changes: 41 additions & 58 deletions examples/maven/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -22,19 +25,17 @@
</modules>

<properties>
<eea.java.version>11</eea.java.version>
<eea.java.version>17</eea.java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- The dual use of org.eclipse.jdt.annotation.Nullable
as well as javax.annotation.Nullable from FindBugs
is to illustrate interop. You could, of course,
choose only one of them for your project. -->
<!-- The dual use of org.eclipse.jdt.annotation.Nullable as well as javax.annotation.Nullable from FindBugs
is to illustrate interop. You could, of course, choose only one of them for your project. -->
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.annotation</artifactId>
<version>2.1.0</version>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -57,59 +58,31 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
<version>2.0.16</version>
</dependency>
<dependency>
<groupId>org.lastnpe.eea</groupId>
<artifactId>jdk-eea</artifactId>
<artifactId>java-${eea.java.version}-eea</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.lastnpe.eea</groupId>
<artifactId>slf4j-api-eea</artifactId>
<artifactId>slf4j-api-2-eea</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.10,)</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<!-- https://eclipse.dev/m2e/documentation/release-notes-17.html#new-syntax-for-specifying-lifecycle-mapping-metadata -->
<?m2e ignore?>
<id>unpack-jdt-ecj-settings</id>
<goals>
<goal>unpack</goal>
Expand All @@ -132,45 +105,55 @@
</execution>
</executions>
</plugin>
<plugin>
<!-- TODO disabling toolchains plugin that was enabled in parent pom.
still seems not be compatible with maven-compiler-plugin + tycho-compiler-jdt -->
<artifactId>maven-toolchains-plugin</artifactId>
<executions>
<execution>
<id>toolchain@validate</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${eea.java.version}</release>
<showWarnings>true</showWarnings>
<!-- TODO Bug, this does not actually seem to work for alternative compilerId? -->
<failOnWarning>true</failOnWarning>
<failOnWarning>false</failOnWarning>
<compilerId>jdt</compilerId>
<compilerArguments>
<!-- The -annotationpath "CLASSPATH" here causes the JDT ECJ Batch Compiler
to (quote) "When annotation based null analysis is enabled (...),
lookup external annotations from the classpath and sourcepath."
<compilerArgs>
<!-- The -annotationpath "CLASSPATH" here causes the JDT ECJ Batch Compiler to (quote)
"When annotation based null analysis is enabled (...), lookup external annotations from the classpath and sourcepath."
@see http://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_batch_compiler.htm
-->
<annotationpath>CLASSPATH</annotationpath>
<properties>${project.build.directory}/org.eclipse.jdt.core.prefs</properties>
<arg>-annotationpath</arg>
<arg>CLASSPATH</arg>

<arg>-properties</arg>
<arg>${project.build.directory}/org.eclipse.jdt.core.prefs</arg>
<!-- NB: It's NOT possible to list *.prefs properties directly here; see https://issues.apache.org/jira/browse/MCOMPILER-123
<org.eclipse.jdt.core.compiler.annotation.nullanalysis>enabled</org.eclipse.jdt.core.compiler.annotation.nullanalysis>
<org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations>true</org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations>
-->
</compilerArguments>
<!-- Following is an alternative, but it's less ideal, because you would have to manually

<!-- Following is an alternative, but it's less ideal, because you would have to manually
map and maintain the org.eclipse.jdt.core.prefs properties to options listed on
http://help.eclipse.org/neon/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/task-using_batch_compiler.htm
<compilerArgument>-err:nullAnnot,null,-missingNullDefault</compilerArgument>
-->
<failOnWarning>false</failOnWarning>
<arg>-err:nullAnnot,null,-missingNullDefault</arg>
-->
</compilerArgs>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-jdt</artifactId>
<version>2.0.0</version>
<version>3.0.5</version>
</dependency>
<dependency>
<!-- NB: This dependency is, intentionally, duplicated above
(other one is for CLI mvn; this one is read by eclipse-external-annotations-m2e-plugin
in-IDE to configure the Project Properties via JDT) -->
<!-- NB: This dependency is, intentionally, duplicated above (other one is for CLI mvn; this one is
read by eclipse-external-annotations-m2e-plugin in-IDE to configure the Project Properties via JDT) -->
<groupId>org.lastnpe.examples</groupId>
<artifactId>jdt-ecj-settings</artifactId>
<version>${project.version}</version>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
<module>generator</module>
<module>libraries</module>
<module>eea-all</module>
<!--TODO <module>examples/maven</module>-->
<module>examples/maven</module>
</modules>

<profiles>
Expand Down

0 comments on commit 5b59e61

Please sign in to comment.