Update dependencies, use java 21, generate sealed types

This commit is contained in:
Andrea Cavalli 2023-11-05 19:55:18 +01:00
parent 5a10da543d
commit 6cc6894528
3 changed files with 22 additions and 10 deletions

View File

@ -16,7 +16,7 @@
<properties> <properties>
<revision>1.0.0.0-SNAPSHOT</revision> <revision>1.0.0.0-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<fastutil.version>8.5.11</fastutil.version> <fastutil.version>8.5.12</fastutil.version>
<maven.version>4.0.0-alpha-3</maven.version> <maven.version>4.0.0-alpha-3</maven.version>
</properties> </properties>
<repositories> <repositories>
@ -59,7 +59,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId> <artifactId>maven-plugin-plugin</artifactId>
<version>3.7.1</version> <version>3.10.1</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.maven.plugin-tools</groupId> <groupId>org.apache.maven.plugin-tools</groupId>
@ -84,7 +84,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version> <version>3.10.1</version>
<configuration> <configuration>
<release>17</release> <release>21</release>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
@ -185,7 +185,7 @@
<dependency> <dependency>
<groupId>org.yaml</groupId> <groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId> <artifactId>snakeyaml</artifactId>
<version>1.33</version> <version>2.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.fabricmc</groupId> <groupId>net.fabricmc</groupId>
@ -195,7 +195,7 @@
<dependency> <dependency>
<groupId>org.jetbrains</groupId> <groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId> <artifactId>annotations</artifactId>
<version>23.1.0</version> <version>24.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.unimi.dsi</groupId> <groupId>it.unimi.dsi</groupId>
@ -217,7 +217,7 @@
<dependency> <dependency>
<groupId>org.apache.maven.plugin-tools</groupId> <groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId> <artifactId>maven-plugin-annotations</artifactId>
<version>3.7.1</version> <version>3.8.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -233,7 +233,7 @@
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId> <artifactId>log4j-core</artifactId>
<version>2.19.0</version> <version>2.20.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
@ -243,7 +243,7 @@
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId> <artifactId>log4j-slf4j2-impl</artifactId>
<version>2.19.0</version> <version>2.20.0</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@ -3,6 +3,7 @@ package it.cavallium.datagen.plugin.classgen;
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeSpec;
import it.cavallium.datagen.plugin.ClassGenerator; import it.cavallium.datagen.plugin.ClassGenerator;
import it.cavallium.datagen.plugin.ComputedTypeSuper; import it.cavallium.datagen.plugin.ComputedTypeSuper;
@ -36,6 +37,17 @@ public class GenDataSuperX extends ClassGenerator {
classBuilder.addModifiers(Modifier.PUBLIC); classBuilder.addModifiers(Modifier.PUBLIC);
if (version.isCurrent()) {
classBuilder.addModifiers(Modifier.SEALED);
Stream<TypeName> superTypesThatExtendThisSuperType = dataModel.getSuperTypesComputed(version)
.filter(computedTypeSuper -> dataModel.getExtendsInterfaces(computedTypeSuper).anyMatch(typeSuper::equals))
.map(computedTypeSuper -> computedTypeSuper.getJTypeName(basePackageName));
Stream<TypeName> subTypes = typeSuper.subTypes().stream()
.map(subType -> subType.getJTypeName(basePackageName));
Stream<TypeName> permittedSubclasses = Stream.concat(superTypesThatExtendThisSuperType, subTypes).distinct();
classBuilder.addPermittedSubclasses(permittedSubclasses.toList());
}
dataModel.getTypeSameVersions(typeSuper).forEach(v -> { dataModel.getTypeSameVersions(typeSuper).forEach(v -> {
var iTypeClass = ClassName.get(v.getPackage(basePackageName), "IBaseType"); var iTypeClass = ClassName.get(v.getPackage(basePackageName), "IBaseType");
classBuilder.addSuperinterface(iTypeClass); classBuilder.addSuperinterface(iTypeClass);

View File

@ -67,7 +67,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.8.1</version>
<configuration> <configuration>
<release>17</release> <release>21</release>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
@ -159,7 +159,7 @@
</goals> </goals>
</pluginExecutionFilter> </pluginExecutionFilter>
<action> <action>
<ignore></ignore> <ignore/>
</action> </action>
</pluginExecution> </pluginExecution>
</pluginExecutions> </pluginExecutions>