diff --git a/annotations/build.gradle b/annotations/build.gradle deleted file mode 100644 index df10a68..0000000 --- a/annotations/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -sourceSets.main { - multirelease { - alternateVersions 9 - moduleName "org.spongepowered.eventimplgen.annotations" - requireAllPackagesExported() - } -} \ No newline at end of file diff --git a/annotations/src/main/java/module-info.java b/annotations/src/main/java/module-info.java new file mode 100644 index 0000000..cf8b381 --- /dev/null +++ b/annotations/src/main/java/module-info.java @@ -0,0 +1,4 @@ +module org.spongepowered.eventgen.annotations { + exports org.spongepowered.eventgen.annotations; + exports org.spongepowered.eventgen.annotations.internal; +} \ No newline at end of file diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/AbsoluteSortPosition.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/AbsoluteSortPosition.java similarity index 97% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/AbsoluteSortPosition.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/AbsoluteSortPosition.java index bcaca5a..fe2000e 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/AbsoluteSortPosition.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/AbsoluteSortPosition.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/FactoryMethod.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/FactoryMethod.java similarity index 97% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/FactoryMethod.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/FactoryMethod.java index 266342a..3ed2e56 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/FactoryMethod.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/FactoryMethod.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/GenerateFactoryMethod.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/GenerateFactoryMethod.java similarity index 97% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/GenerateFactoryMethod.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/GenerateFactoryMethod.java index fa3cbdc..1a847d5 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/GenerateFactoryMethod.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/GenerateFactoryMethod.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/ImplementedBy.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/ImplementedBy.java similarity index 97% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/ImplementedBy.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/ImplementedBy.java index c4e7dca..0b25064 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/ImplementedBy.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/ImplementedBy.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/NoFactoryMethod.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/NoFactoryMethod.java similarity index 96% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/NoFactoryMethod.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/NoFactoryMethod.java index 213af81..1ad1632 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/NoFactoryMethod.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/NoFactoryMethod.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/PropertySettings.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/PropertySettings.java similarity index 97% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/PropertySettings.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/PropertySettings.java index 477b8eb..86e04c1 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/PropertySettings.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/PropertySettings.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/TransformResult.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/TransformResult.java similarity index 97% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/TransformResult.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/TransformResult.java index e13781f..77cf2d3 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/TransformResult.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/TransformResult.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/TransformWith.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/TransformWith.java similarity index 97% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/TransformWith.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/TransformWith.java index 9ab4441..500abb9 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/TransformWith.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/TransformWith.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/UseField.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/UseField.java similarity index 97% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/UseField.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/UseField.java index 2832b62..06a43ed 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/UseField.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/UseField.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen; +package org.spongepowered.eventgen.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/internal/GeneratedEvent.java b/annotations/src/main/java/org/spongepowered/eventgen/annotations/internal/GeneratedEvent.java similarity index 96% rename from annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/internal/GeneratedEvent.java rename to annotations/src/main/java/org/spongepowered/eventgen/annotations/internal/GeneratedEvent.java index 79167f8..a2aacb9 100644 --- a/annotations/src/main/java/org/spongepowered/api/util/annotation/eventgen/internal/GeneratedEvent.java +++ b/annotations/src/main/java/org/spongepowered/eventgen/annotations/internal/GeneratedEvent.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.util.annotation.eventgen.internal; +package org.spongepowered.eventgen.annotations.internal; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/src/main/java9/module-info.java b/annotations/src/main/java9/module-info.java deleted file mode 100644 index c1c5590..0000000 --- a/annotations/src/main/java9/module-info.java +++ /dev/null @@ -1,4 +0,0 @@ -module org.spongepowered.eventimplgen.annotations { - exports org.spongepowered.api.util.annotation.eventgen; - exports org.spongepowered.api.util.annotation.eventgen.internal; -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 958d613..821b26f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,8 @@ plugins { alias(libs.plugins.indra.sonatype) apply false alias(libs.plugins.errorprone) alias(libs.plugins.eclipseApt) + id('java-library') + id("org.gradlex.extra-java-module-info") version "1.9" } // Default tasks @@ -11,16 +13,33 @@ defaultTasks 'spotlessApply', 'build' // Basic project information group = "org.spongepowered" +extraJavaModuleInfo { + deriveAutomaticModuleNamesFromFileNames = true + module("com.google.errorprone:javac-shaded", "com.google.errorprone.javac.shaded") { + exports("com.google.errorprone.javac.shaded") + } + module("io.soabase.java-composer:java-composer", "io.soabase.java.composer") { + exports("com.squareup.javapoet") + requiresTransitive("java.compiler") + } + module("org.jooq:joor-java-8", "org.jooq.joor") { + exports("org.joor") + } +} + allprojects { apply plugin: "org.spongepowered.gradle.sponge.dev" apply plugin: "net.kyori.indra.publishing" apply plugin: "net.ltgt.errorprone" apply plugin: "com.diffplug.eclipse.apt" + apply plugin: "java-library" + apply plugin: "eclipse" dependencies { errorprone libs.errorprone } + eclipse { synchronizationTasks eclipseJdtApt, eclipseJdt, eclipseFactorypath } @@ -51,35 +70,35 @@ allprojects { ) } } + indra { + javaVersions { + minimumToolchain(21) + target(21) + } + } indraSpotlessLicenser { property("name", rootProject.projectName) } -} - -indra { - javaVersions { - testWith(8, 11, 17) + tasks.withType(JavaCompile).configureEach { + options.forkOptions.jvmArgs = [ + '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' + ] } } -sourceSets { - main { - multirelease { - moduleName "org.spongepowered.eventimplgen" - alternateVersions 9, 13 - } - } -} + // Project dependencies dependencies { implementation project(":event-impl-gen-annotations") api libs.javapoet + api libs.javaxInject + api libs.jakartaInject compileOnlyApi libs.errorprone.annotations - api libs.dagger.runtime + api(libs.dagger.runtime) annotationProcessor libs.dagger.compiler compileOnlyApi libs.autoService.annotations diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 11820ee..df0272e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ version = "1.0" [versions] autoService = "1.1.1" checkerQual = "3.26.0" -dagger = "2.51.1" +dagger = "2.52" errorprone = "2.28.0" junit = "5.10.2" @@ -15,8 +15,10 @@ dagger-runtime = { module = "com.google.dagger:dagger", version.ref = "dagger" } dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" } errorprone = { module = "com.google.errorprone:error_prone_core", version.ref = "errorprone" } errorprone-annotations = { module = "com.google.errorprone:error_prone_annotations", version.ref = "errorprone" } -javapoet = { module = "com.squareup:javapoet", version = "1.13.0" } +javapoet = { module = "io.soabase.java-composer:java-composer", version = "1.0" } jetbrainsAnnotations = { module = "org.jetbrains:annotations", version = "24.1.0"} +jakartaInject = { module = "jakarta.inject:jakarta.inject-api", version = "2.0.1" } +javaxInject = { module = "javax.inject:javax.inject", version = "1" } # Tests assertj = { module = "org.assertj:assertj-core", version = "3.26.0" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..df97d72 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java9/module-info.java b/src/main/java/module-info.java similarity index 59% rename from src/main/java9/module-info.java rename to src/main/java/module-info.java index 9238d3c..e8f4f3b 100644 --- a/src/main/java9/module-info.java +++ b/src/main/java/module-info.java @@ -1,14 +1,15 @@ module org.spongepowered.eventimplgen { exports org.spongepowered.eventimplgen.processor; - requires java.compiler; - requires com.squareup.javapoet; - // requires transitive dagger; - requires transitive org.spongepowered.eventimplgen.annotations; + requires dagger; + requires javax.inject; + requires jakarta.inject; + requires io.soabase.java.composer; + requires transitive java.compiler; + requires transitive org.spongepowered.eventgen.annotations; requires static transitive com.google.auto.service; requires static transitive org.jetbrains.annotations; - // requires static transitive javax.inject; TODO maybe? provides javax.annotation.processing.Processor with org.spongepowered.eventimplgen.processor.EventImplGenProcessor; } \ No newline at end of file diff --git a/src/main/java/org/spongepowered/eventimplgen/eventgencore/PropertySorter.java b/src/main/java/org/spongepowered/eventimplgen/eventgencore/PropertySorter.java index eab8194..33cf7af 100644 --- a/src/main/java/org/spongepowered/eventimplgen/eventgencore/PropertySorter.java +++ b/src/main/java/org/spongepowered/eventimplgen/eventgencore/PropertySorter.java @@ -24,7 +24,7 @@ */ package org.spongepowered.eventimplgen.eventgencore; -import org.spongepowered.api.util.annotation.eventgen.AbsoluteSortPosition; +import org.spongepowered.eventgen.annotations.AbsoluteSortPosition; import org.spongepowered.eventimplgen.processor.EventGenOptions; import java.util.ArrayList; diff --git a/src/main/java/org/spongepowered/eventimplgen/factory/ClassContext.java b/src/main/java/org/spongepowered/eventimplgen/factory/ClassContext.java index 7bc5009..fc38608 100644 --- a/src/main/java/org/spongepowered/eventimplgen/factory/ClassContext.java +++ b/src/main/java/org/spongepowered/eventimplgen/factory/ClassContext.java @@ -33,7 +33,7 @@ import dagger.assisted.Assisted; import dagger.assisted.AssistedFactory; import dagger.assisted.AssistedInject; -import org.spongepowered.api.util.annotation.eventgen.UseField; +import org.spongepowered.eventgen.annotations.UseField; import org.spongepowered.eventimplgen.eventgencore.Property; import java.util.Optional; diff --git a/src/main/java/org/spongepowered/eventimplgen/factory/ClassGenerator.java b/src/main/java/org/spongepowered/eventimplgen/factory/ClassGenerator.java index c4afc82..447f9ea 100644 --- a/src/main/java/org/spongepowered/eventimplgen/factory/ClassGenerator.java +++ b/src/main/java/org/spongepowered/eventimplgen/factory/ClassGenerator.java @@ -34,14 +34,13 @@ import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import org.jetbrains.annotations.Nullable; -import org.spongepowered.api.util.annotation.eventgen.PropertySettings; -import org.spongepowered.api.util.annotation.eventgen.UseField; -import org.spongepowered.api.util.annotation.eventgen.internal.GeneratedEvent; +import org.spongepowered.eventgen.annotations.PropertySettings; +import org.spongepowered.eventgen.annotations.UseField; +import org.spongepowered.eventgen.annotations.internal.GeneratedEvent; import org.spongepowered.eventimplgen.eventgencore.Property; import org.spongepowered.eventimplgen.eventgencore.PropertySorter; import org.spongepowered.eventimplgen.factory.plugin.EventFactoryPlugin; import org.spongepowered.eventimplgen.processor.EventImplGenProcessor; -import org.spongepowered.eventimplgen.signature.Descriptors; import java.util.List; import java.util.Objects; diff --git a/src/main/java/org/spongepowered/eventimplgen/factory/FactoryInterfaceGenerator.java b/src/main/java/org/spongepowered/eventimplgen/factory/FactoryInterfaceGenerator.java index 9ff89bf..441cb43 100644 --- a/src/main/java/org/spongepowered/eventimplgen/factory/FactoryInterfaceGenerator.java +++ b/src/main/java/org/spongepowered/eventimplgen/factory/FactoryInterfaceGenerator.java @@ -31,7 +31,7 @@ import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; -import org.spongepowered.api.util.annotation.eventgen.internal.GeneratedEvent; +import org.spongepowered.eventgen.annotations.internal.GeneratedEvent; import org.spongepowered.eventimplgen.eventgencore.Property; import org.spongepowered.eventimplgen.eventgencore.PropertySorter; diff --git a/src/main/java/org/spongepowered/eventimplgen/factory/plugin/AccessorModifierEventFactoryPlugin.java b/src/main/java/org/spongepowered/eventimplgen/factory/plugin/AccessorModifierEventFactoryPlugin.java index 5301b6f..61151d6 100644 --- a/src/main/java/org/spongepowered/eventimplgen/factory/plugin/AccessorModifierEventFactoryPlugin.java +++ b/src/main/java/org/spongepowered/eventimplgen/factory/plugin/AccessorModifierEventFactoryPlugin.java @@ -26,8 +26,8 @@ import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.TypeName; -import org.spongepowered.api.util.annotation.eventgen.TransformResult; -import org.spongepowered.api.util.annotation.eventgen.TransformWith; +import org.spongepowered.eventgen.annotations.TransformResult; +import org.spongepowered.eventgen.annotations.TransformWith; import org.spongepowered.eventimplgen.eventgencore.Property; import org.spongepowered.eventimplgen.factory.ClassContext; diff --git a/src/main/java/org/spongepowered/eventimplgen/processor/EventGenOptions.java b/src/main/java/org/spongepowered/eventimplgen/processor/EventGenOptions.java index a3e36f6..1d4967f 100644 --- a/src/main/java/org/spongepowered/eventimplgen/processor/EventGenOptions.java +++ b/src/main/java/org/spongepowered/eventimplgen/processor/EventGenOptions.java @@ -25,8 +25,8 @@ package org.spongepowered.eventimplgen.processor; import org.jetbrains.annotations.Nullable; -import org.spongepowered.api.util.annotation.eventgen.GenerateFactoryMethod; -import org.spongepowered.api.util.annotation.eventgen.NoFactoryMethod; +import org.spongepowered.eventgen.annotations.GenerateFactoryMethod; +import org.spongepowered.eventgen.annotations.NoFactoryMethod; import java.util.Arrays; import java.util.Collections; diff --git a/src/main/java/org/spongepowered/eventimplgen/processor/EventImplGenProcessor.java b/src/main/java/org/spongepowered/eventimplgen/processor/EventImplGenProcessor.java index 1ede3be..4d67836 100644 --- a/src/main/java/org/spongepowered/eventimplgen/processor/EventImplGenProcessor.java +++ b/src/main/java/org/spongepowered/eventimplgen/processor/EventImplGenProcessor.java @@ -25,7 +25,7 @@ package org.spongepowered.eventimplgen.processor; import com.google.auto.service.AutoService; -import org.spongepowered.api.util.annotation.eventgen.internal.GeneratedEvent; +import org.spongepowered.eventgen.annotations.internal.GeneratedEvent; import java.io.IOException; import java.util.HashSet; diff --git a/src/main/java/org/spongepowered/eventimplgen/processor/EventImplWriter.java b/src/main/java/org/spongepowered/eventimplgen/processor/EventImplWriter.java index bc5231b..146829f 100644 --- a/src/main/java/org/spongepowered/eventimplgen/processor/EventImplWriter.java +++ b/src/main/java/org/spongepowered/eventimplgen/processor/EventImplWriter.java @@ -27,7 +27,7 @@ import com.squareup.javapoet.ClassName; import com.squareup.javapoet.JavaFile; import org.jetbrains.annotations.Nullable; -import org.spongepowered.api.util.annotation.eventgen.ImplementedBy; +import org.spongepowered.eventgen.annotations.ImplementedBy; import org.spongepowered.eventimplgen.AnnotationUtils; import org.spongepowered.eventimplgen.eventgencore.Property; import org.spongepowered.eventimplgen.eventgencore.PropertySorter; diff --git a/src/main/java/org/spongepowered/eventimplgen/processor/EventScanner.java b/src/main/java/org/spongepowered/eventimplgen/processor/EventScanner.java index 87d02a8..d2eae4a 100644 --- a/src/main/java/org/spongepowered/eventimplgen/processor/EventScanner.java +++ b/src/main/java/org/spongepowered/eventimplgen/processor/EventScanner.java @@ -25,24 +25,11 @@ package org.spongepowered.eventimplgen.processor; import org.jetbrains.annotations.Nullable; -import org.spongepowered.api.util.annotation.eventgen.FactoryMethod; -import org.spongepowered.api.util.annotation.eventgen.internal.GeneratedEvent; +import org.spongepowered.eventgen.annotations.FactoryMethod; +import org.spongepowered.eventgen.annotations.internal.GeneratedEvent; import org.spongepowered.eventimplgen.AnnotationUtils; import org.spongepowered.eventimplgen.eventgencore.PropertySearchStrategy; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Queue; -import java.util.Set; -import java.util.regex.Pattern; -import java.util.stream.Stream; - import javax.annotation.processing.Messager; import javax.annotation.processing.RoundEnvironment; import javax.inject.Inject; @@ -61,6 +48,18 @@ import javax.lang.model.util.Elements; import javax.lang.model.util.Types; import javax.tools.Diagnostic; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Queue; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Stream; public class EventScanner { @@ -287,19 +286,25 @@ class PackageNode { Stream childPackages() { return this.knownChildren.entrySet().stream() - .map(ent -> { - final PackageNode node = ent.getValue(); - // this will fill in missing package elements, assuming that traverse the package tree top-down - // that is true for EIG, but may not be true generally - if (node.self == null && this.self != null) { - node.self = EventScanner.this.elements.getPackageElement(this.self.getQualifiedName().toString() + '.' + ent.getKey()); + .filter(Objects::nonNull) + .flatMap(entry -> { + final PackageNode childNode = entry.getValue(); + + // If `self` is null, attempt to retrieve it + if (childNode.self == null && this.self != null) { + // Build the full package name based on the parent's qualified name + String packageName = this.self.getQualifiedName().toString() + '.' + entry.getKey(); + childNode.self = EventScanner.this.elements.getPackageElement(packageName); } - if (node.self == null) { - if (EventScanner.this.debugMode) { - EventScanner.this.messager.printMessage(Diagnostic.Kind.NOTE, "No self for node " + node + " as child of " + this); - } + + // If `self` is still null, the package is empty but may have children + if (childNode.self == null) { + // Recursively explore the children of this empty package + return childNode.childPackages(); } - return node.self; + + // If the package is not empty, return the package along with any nested child packages + return Stream.concat(Stream.of(childNode.self), childNode.childPackages()); }) .filter(Objects::nonNull); } diff --git a/src/main/java13/org/spongepowered/eventimplgen/processor/PreviewFeatureShim.java b/src/test/java/org/spongepowered/eventimplgen/demo/Event.java similarity index 78% rename from src/main/java13/org/spongepowered/eventimplgen/processor/PreviewFeatureShim.java rename to src/test/java/org/spongepowered/eventimplgen/demo/Event.java index 5cb363e..47a17dc 100644 --- a/src/main/java13/org/spongepowered/eventimplgen/processor/PreviewFeatureShim.java +++ b/src/test/java/org/spongepowered/eventimplgen/demo/Event.java @@ -22,17 +22,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.eventimplgen.processor; +package org.spongepowered.eventimplgen.demo; -import javax.annotation.processing.ProcessingEnvironment; - -/** - * Multi-release shim for {@code isPreviewEnabled()} - */ -final class PreviewFeatureShim { - - static boolean previewFeaturesEnabled(final ProcessingEnvironment environment) { - return environment.isPreviewEnabled(); - } +public interface Event { } diff --git a/test-data/src/main/java/test/event/Event.java b/test-data/src/main/java/test/event/Event.java index 93dd8c2..d6cb2a5 100644 --- a/test-data/src/main/java/test/event/Event.java +++ b/test-data/src/main/java/test/event/Event.java @@ -24,7 +24,7 @@ */ package test.event; -import org.spongepowered.api.util.annotation.eventgen.NoFactoryMethod; +import org.spongepowered.eventgen.annotations.NoFactoryMethod; /** * Base interface for events. diff --git a/test-data/src/main/java/test/event/GenericEvent.java b/test-data/src/main/java/test/event/GenericEvent.java index 8c8364f..675d5c8 100644 --- a/test-data/src/main/java/test/event/GenericEvent.java +++ b/test-data/src/main/java/test/event/GenericEvent.java @@ -24,7 +24,7 @@ */ package test.event; -import org.spongepowered.api.util.annotation.eventgen.NoFactoryMethod; +import org.spongepowered.eventgen.annotations.NoFactoryMethod; import test.TypeToken; @NoFactoryMethod diff --git a/test-data/src/main/java/test/event/cause/package-info.java b/test-data/src/main/java/test/event/cause/package-info.java index 0ff436e..4b8a4c3 100644 --- a/test-data/src/main/java/test/event/cause/package-info.java +++ b/test-data/src/main/java/test/event/cause/package-info.java @@ -25,4 +25,4 @@ @NoFactoryMethod package test.event.cause; -import org.spongepowered.api.util.annotation.eventgen.NoFactoryMethod; \ No newline at end of file +import org.spongepowered.eventgen.annotations.NoFactoryMethod; \ No newline at end of file diff --git a/test-data/src/main/java/test/event/package-info.java b/test-data/src/main/java/test/event/package-info.java index 718ecc5..d108082 100644 --- a/test-data/src/main/java/test/event/package-info.java +++ b/test-data/src/main/java/test/event/package-info.java @@ -25,4 +25,4 @@ @GenerateFactoryMethod package test.event; -import org.spongepowered.api.util.annotation.eventgen.GenerateFactoryMethod; \ No newline at end of file +import org.spongepowered.eventgen.annotations.GenerateFactoryMethod; \ No newline at end of file diff --git a/test-data/src/test/java/test/event/TestEventFactoryTest.java b/test-data/src/test/java/test/event/TestEventFactoryTest.java index 092ec83..ee5d744 100644 --- a/test-data/src/test/java/test/event/TestEventFactoryTest.java +++ b/test-data/src/test/java/test/event/TestEventFactoryTest.java @@ -26,13 +26,8 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import test.TypeToken; -import test.event.lifecycle.ConnectionEvent; import test.event.lifecycle.NestedTest; -import java.nio.ByteBuffer; -import java.util.Collections; - class TestEventFactoryTest { @Test