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

View File

@ -3,6 +3,7 @@ package it.cavallium.datagen.plugin.classgen;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import it.cavallium.datagen.plugin.ClassGenerator;
import it.cavallium.datagen.plugin.ComputedTypeSuper;
@ -36,6 +37,17 @@ public class GenDataSuperX extends ClassGenerator {
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 -> {
var iTypeClass = ClassName.get(v.getPackage(basePackageName), "IBaseType");
classBuilder.addSuperinterface(iTypeClass);

View File

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