Conversation
Updated the <revision> property in pom.xml to prepare for the next development iteration.
Introduce a new microsphere-jdk-tools Maven module. Adds pom.xml with dependencies (microsphere-java-core, JUnit, Mockito, Logback), maven-compiler config and maven-shade setup. Implements io.microsphere.jdk.tools.compiler.Compiler — a utility to programmatically compile Java sources, manage source/target paths, detect class/root/source locations, and configure processors/options/diagnostics. Includes unit tests (CompilerTest) covering constructors, default path detection, options, processors and compile flow, and a logback-test.xml for test logging.
Introduce Mockito to the parent POM: add a mockito.version property and a mockito-core dependency so tests can use Mockito. Also update JUnit versions: bump the root junit.version 6.0.1 → 6.0.2 and the profile's junit.version 5.13.4 → 5.14.2. The profile also sets mockito.version (4.11.0) to override the parent value.
Introduce a new microsphere-java-test Maven module providing testing utilities and fixtures. Adds pom.xml (compiler/shade configuration and test dependencies), a TestAnnotation and annotation-processing test infrastructure (AbstractAnnotationProcessingTest, AnnotationProcessingTestProcessor, CompilerInvocationInterceptor) that compiles test sources and runs processors during JUnit5 tests. Also adds a set of model classes, service interfaces/implementations, unit tests, logback-test.xml, and a service provider entry for annotation processors to support annotation-processing test cases.
Refactor annotation-processing test harness to use JUnit 5 reflective invocation API. AbstractAnnotationProcessingTest: remove ThreadLocal holder and @BeforeEach/@AfterEach, change beforeTest/afterTest signatures to accept ReflectiveInvocationContext and ExtensionContext (afterTest also receives result and failure), add necessary imports and reflection types. AnnotationProcessingTestProcessor: make package-private, use Invocation type directly, call beforeTest/afterTest with contexts and pass result/failure, and populate processingEnv, Elements/Types and test type information during prepare. CompilerInvocationInterceptor: make package-private, obtain test instance from invocationContext target, use the test class loader, and load SPI Processor implementations via ServiceLoader (merging them with the test processor). Also cleanup imports/usages in test class (remove assertion referencing removed holder). Overall adjusts lifecycle integration so the annotation processor drives the test invocation and reporting.
Add a new JUnit test class TestServiceImplTest (Mockito-based) to validate TestServiceImpl behavior (echo, close, constructors and DI). Make small API/encapsulation adjustments to the annotation-processing test infra: add Javadoc/comments for addCompiledClasses, beforeTest and afterTest in AbstractAnnotationProcessingTest; reduce visibility of AnnotationProcessingTestProcessor constructor and prepare method to package-private; and rename local variables in CompilerInvocationInterceptor to improve clarity and pass the test instance into the processor. These changes improve test coverage and tighten processor APIs.
Introduce io.microsphere.util.ThrowableUtils: a new utility class (with ASF license header and author info) providing getRootCause(Throwable) to traverse and return the deepest cause in a throwable chain. The class implements Utils and has a private constructor to prevent instantiation.
Add JUnit 5 tests for ThrowableUtils#getRootCause. The new test file verifies retrieving the root cause from a nested Throwable, checks behavior when using ThrowableAction.execute to handle thrown exceptions, and ensures rethrowing the root cause yields the expected NullPointerException.
Introduce a failing test and verify test lifecycle failure handling. Adds testOnFailure() which throws a RuntimeException("For testing") and overrides afterTest(ReflectiveInvocationContext<Method>, ExtensionContext, Object, Throwable) to assert the failure message when a failure is present. Also adds the required imports and an assertEquals assertion.
Add Microsphere test libraries to the module POM (microsphere-lang-model, microsphere-jdk-tools (test scope), and microsphere-java-test (test scope)). Update unit tests to extend AbstractAnnotationProcessingTest and adjust lifecycle hooks: beforeTest/afterTest signatures now accept ReflectiveInvocationContext<Method> and ExtensionContext (and afterTest includes result/failure). Import necessary classes (ReflectiveInvocationContext, ExtensionContext, Method) and update test setup/teardown to use the new testing extension API.
Delete the entire microsphere-annotation-processor module: remove source files under src/main/java (annotation model elements, visitors and various utility classes such as AnnotationUtils, ClassUtils, ConstructorUtils, ElementUtils, ExecutableElementComparator, FieldUtils, LoggerUtils, MemberUtils, MessagerUtils, MethodUtils, TypeUtils, etc.) and corresponding unit tests under src/test/java. This change removes the annotation processing implementation and its tests from the repository.
Introduce a new microsphere-lang-model Maven module. Adds pom.xml with dependencies and build configuration, core language-model classes (e.g. StringAnnotationValue) and a comprehensive set of utility classes for annotation/element processing (AnnotationUtils, ClassUtils, ConstructorUtils, ElementUtils, ExecutableElementComparator, FieldUtils, MethodUtils, TypeUtils, Resolvable/JSON visitors, LoggerUtils, MessagerUtils, MemberUtils, etc.). Includes unit tests for the added utilities and elements to validate behavior. This module provides reusable helpers for working with javax.lang.model types and annotation processing within the Microsphere project.
Replace references to io.microsphere.annotation.processor.util.* with the new io.microsphere.lang.model.util.* equivalents across the annotation processor (MessagerUtils, AnnotationUtils, ElementUtils, TypeUtils, ClassUtils, JSONElementVisitor). Update Javadoc and fully-qualified references where needed. Simplify ConfigurationPropertyAnnotationProcessorTest by using AbstractAnnotationProcessingTest and removing an unused lifecycle override. Update pom dependency management and dependencies to add microsphere-java-core and microsphere-lang-model, replace microsphere-java-core dependency usage with microsphere-jdk-tools, and add microsphere-java-test to reflect module relocations.
Add new modules to the parent POM and reorder existing entries. This commit introduces microsphere-jdk-tools, microsphere-java-test, and microsphere-lang-model to the <modules> section and moves microsphere-annotation-processor to the end of the list so the module ordering reflects the updated project structure.
Remove the <build> sections from microsphere-java-test, microsphere-jdk-tools, and microsphere-lang-model POMs. This deletes the maven-compiler-plugin configuration (compilerArgument -proc:none) and the maven-shade-plugin execution that shaded io.github.microsphere-projects:microsphere-java-core, consolidating/cleaning up module-level build configuration.
Move javax.ws.rs and jaxws-api version properties into the parent pom and add dependencyManagement entries for javax.ws.rs-api and jaxws-api. Remove duplicate properties and explicit version elements from module poms (annotation-processor, lang-model, java-test) so they inherit the parent-managed versions. Adjust microsphere-java-dependencies to reorder artifactIds (swap mappings between microsphere-lang-model, microsphere-jdk-tools, microsphere-annotation-processor, and microsphere-java-test). Delete the TestProcessor test class and its service registration (META-INF/services) from the java-test module.
Reorder and group static imports in FieldUtils for consistency and readability. Remove an unused import (AbstractAnnotationProcessingTest) from JSONElementVisitorTest to eliminate a compiler/IDE warning. No behavior changes.
Normalize and tidy imports across multiple modules: reorder static imports for consistency, remove unused imports (including AbstractAnnotationProcessingTest in tests), and fix minor formatting. Replace Mockito wildcard import with explicit mock import in TestServiceImplTest. These are code-cleanup changes to reduce warnings and improve import organization.
Create a new microsphere-java-annotations module and move annotation sources and tests from microsphere-java-core into it. Added a module POM (including jsr305 and JUnit test deps), new NonnullTest and NullableTest classes, and updated test Javadocs. Updated microsphere-java-core POM to depend on the new annotations artifact (replacing the previous direct jsr305 dependency), added the annotations artifact to dependencyManagement, and registered the new module in the root POM. Also removed an unused import in Since.java.
Update the project's parent POM from io.github.microsphere-projects:microsphere-build:0.2.2 to 0.2.3 to incorporate upstream build configuration changes and fixes.
Add JSR-305 (com.google.code.findbugs:jsr305) as a test-scoped dependency in microsphere-java-core/pom.xml. This brings in standard nullability annotations for use in tests and static analysis during the test phase.
Replace checked-in maven-wrapper binary with the newer wrapper scripts and properties. Removes .mvn/wrapper/maven-wrapper.jar, updates .mvn/wrapper/maven-wrapper.properties to wrapperVersion=3.3.4 and points distributionUrl to an aliyun mirror (apache-maven-3.9.9) using distributionType=only-script. Replaces mvnw and mvnw.cmd with revamped wrapper implementations that download/install Maven on demand, add support for MVNW_REPOURL/MVNW_USERNAME/MVNW_PASSWORD/MVNW_VERBOSE, improve Java detection and error handling, support checksum validation, and add mvnd handling.
Bump GitHub Actions steps to v5 (actions/checkout and actions/setup-java) and switch the build command to use the project Maven wrapper (./mvnw) instead of system mvn. Removed the setup-java cache configuration; this ensures the workflow uses the updated action versions and a consistent, project-provided Maven runtime for builds.
Bump actions/checkout and actions/setup-java from v4 to v5 in .github/workflows/maven-publish.yml. Java 11 (Temurin) configuration remains unchanged. Update brings the workflow to the latest major action releases for improvements, fixes, and security updates.
Provide a base beforeTest implementation in UtilTest that initializes testTypeElement from TestServiceImpl and add required imports (TestServiceImpl, ReflectiveInvocationContext, ExtensionContext, Method). Update several test classes (ElementUtilsTest, JSONAnnotationValueVisitorTest, MessagerUtilsTest, MethodUtilsTest, ResolvableAnnotationValueVisitorTest) to call super.beforeTest(invocationContext, extensionContext) at the start of their overridden beforeTest methods so the shared setup runs correctly.
Introduce initTestClass(Class<?>) to centralize initialization of test class metadata for annotation-processing tests. The new method sets testClass, testClassName, resolves testTypeElement via Elements, assigns testTypeMirror and casts it to testDeclaredType (DeclaredType). This consolidates repeated setup logic and prepares type information for subsequent processing.
Update ResolvableAnnotationValueVisitorTest to explicitly reference instance fields by prefixing with 'this.' (visitor, visitor1, visitor2, testTypeElement) to avoid ambiguity and improve clarity. Also fix a duplicated assertion in testVisitString to use visitor2 for the third check.
Rename and reorganize tests in JSONElementVisitorTest to match the visited element types and assertions. Test method names were corrected (package, variable, executable, type, type-parameter) and assertions updated to call the appropriate visitor methods and element getters; a missing test for visitTypeParameter when unsupported was added. Minor formatting cleanup included.
If supportsType(e) is false, visitType now returns immediately to avoid processing unsupported types. Also initialize 'appended' from super.visitType(e, jsonBuilder) and keep existing member-visit logic, simplifying control flow and making behavior more explicit.
Replace manual .get(0) checks with ListUtils.first by adding a static import and using first(annotations) in AnnotationUtils. Simplifies code for obtaining the first annotation and centralizes handling of empty lists.
Replace manual empty-check and get(0) pattern with a static import of ListUtils.first when returning the first declared method. Adds import io.microsphere.collection.ListUtils.first and uses first(allDeclaredMethods) to keep the previous null-on-empty behavior while simplifying the code.
Deleted the <optional>true</optional> element from the microsphere-java-core dependency in microsphere-java-test/pom.xml so the core artifact is no longer optional and will be included on the test module's classpath (ensuring tests have access to core).
Update ElementUtilsTest to consistently reference the instance field by qualifying echoMethod with this. Also add additional null-case assertions for matchParameterTypes (NULL_METHOD and NULL_CLASS_ARRAY) and normalize spacing in super.beforeTest. These changes improve clarity and null-safety in the test code.
Add a null-case assertion to ClassUtilsTest: import assertNull and assert that loadClass("not-found-class") returns null. This verifies that loadClass handles unknown class names gracefully.
After invoking afterTest, if a test produced a failure, extract its root cause and rethrow it wrapped as an Error to preserve the original cause and halt processing. Adds static imports for ExceptionUtils.wrap and ThrowableUtils.getRootCause.
Replace a bare matchesElementType call with explicit assertions in ElementUtilsTest: assertTrue for the expected TYPE match and assertFalse for a non-matching PACKAGE. This makes the test verify both positive and negative outcomes rather than relying on a no-op call.
Change ApplicationContext and Environment field visibility from package-private to protected so subclasses can access them directly. @Autowired on the ApplicationContext is retained; Environment remains unannotated.
Replace PRIVATE with PROTECTED in the import and the assertion so the test verifies the protected modifier on the field. This aligns the test expectation with the field's actual visibility.
Update the expected JSON fragment in testVisit from "io.microsphere.annotation.processor.GenericTestService" to "io.microsphere.test.service.GenericTestService" to match the class/package change. This keeps the test assertion in microsphere-lang-model/src/test/java/io/microsphere/lang/model/util/JSONAnnotationValueVisitorTest.java in sync with the refactored/relocated test service class.
Replace outdated package references in JSONElementVisitorTest: change io.microsphere.annotation.processor.model.util to io.microsphere.lang.model.util in testVisitPackage and testVisitPackageOnUnsupported. Keeps tests aligned with the current package structure after refactor.
Make AnnotationProcessingTest a JUnit 5 exception handler and use it as an extension for testOnFailure. The class now implements TestExecutionExceptionHandler and is applied to the failing test with @ExtendWith(AnnotationProcessingTest.class). handleTestExecutionException suppresses the RuntimeException thrown by testOnFailure so the test can exercise failure behavior without failing the whole test run. Added the required JUnit imports.
Remove the trailing newline at end-of-file for microsphere-java-test/src/test/java/io/microsphere/test/annotation/processing/AnnotationProcessingTest.java. No other code changes were made.
Add junit-platform.properties to enable JUnit Jupiter extension autodetection and parallel test execution. Sets junit.jupiter.extensions.autodetection.enabled=true and configures parallel execution mode to concurrent for both default and classes, improving test discovery and runtime performance. File added at microsphere-java-test/src/main/resources.
Simplify AnnotationUtils.getElementValue: narrow attribute method search by combining the missing-value and name match into the predicate, use first(...) to pick the attribute method, and return null early if no value is found. Update unit tests to reference super.testTypeElement/testTypeMirror consistently, add missing imports (PAYLOAD, assertNotNull), and introduce new tests for default-attribute-null and element-not-found cases. Also strengthen assertAttributeEntry (null checks and clearer expected-value comparison) and adjust related helper methods to match the new behaviors.
Add an assertion to verify matchesAttributeValue returns false when the first argument is null and the second is a non-null AnnotationValue. Strengthens null-safety coverage in AnnotationUtils tests.
Add an explicit null check and early return in TypeUtils.isTypeElement to avoid calling declaredType.asElement() when declaredType is null. This prevents a potential NPE and improves readability of the method.
Replace inline logical-and guard returns with explicit if-checks in visitPackage, visitVariable, visitExecutable and visitTypeParameter. Behavior is unchanged; this refactor improves readability and makes it easier to set breakpoints during debugging.
Replace the inline null-check return with an explicit if-block in AnnotationUtils.matchesDefaultAttributeValue to improve readability. The method now returns false immediately if attributeMethod is null, then delegates to matchesAttributeValue for the default value; no behavioral change intended.
Refactor CompilerInvocationInterceptor to build a Class<?>[] from the collected Set and pass that array to Compiler APIs. Added a static import of EMPTY_CLASS_ARRAY and renamed the Set to compiledClassesSet to avoid naming confusion. This ensures typed empty-array usage with toArray(EMPTY_CLASS_ARRAY) and uses the resulting Class[] for sourcePaths(...) and compile(...), removing ad-hoc toArray(new Class[0]) calls.
Move AnnotatedElementJSONElementVisitor to microsphere-lang-model and update packages/usages; make ConfigurationPropertyJSONElementVisitor package-private, change its CONFIGURATION_PROPERTY_ANNOTATION_CLASS_NAME and constructor visibility, and override supportsType to always return true. Update ConfigurationPropertyAnnotationProcessor to import ResourceConstants, adjust static import path, refactor resolveMetadata into an overload that accepts a Set (prepend '[' before resolving, append generated SPI JSON, and ensure proper trailing bracket handling), and add a toJSON() helper. Update and add unit tests to match the refactor: adapt ConfigurationPropertyAnnotationProcessorTest, add ConfigurationPropertyJSONElementVisitorTest, and add AnnotatedElementJSONElementVisitorTest under the lang-model tests. Miscellaneous import and formatting adjustments applied to affected files.
Pass the attribute name into setSources and make the method process only when attributeName equals "source". This avoids treating non-source annotation attributes as sources when the visitor's default branch invokes setSources. The method visibility was relaxed and a unit test (testSetSourcesOnNoSource) was added to ensure calling setSources with a non-'source' attribute and null values does not throw.
Extend ResourceProcessorTest to cover fallback/error-handler behavior when resource callbacks throw. Add assertions that: - classOutputProcessor.processInResource with a throwing callback returns null when a handler returning null is provided. - sourcePathProcessor.processInResourceInputStream/Reader/Content with throwing callbacks return Optional.empty() when a handler returning null is provided. - classOutputProcessor.processInResourceOutputStream and processInResourceWriter invoke the error handler and receive a non-null exception. These tests ensure resource processors correctly propagate exceptions to provided handlers and return the expected fallback values.
Introduce TestDeque (backed by LinkedList) as a reusable test implementation of AbstractDeque with configurable max capacity. Replace the large anonymous deque instance in AbstractDequeTest#setUp with TestDeque<>(1), remove now-unused imports, and update the testRemoveFirstOccurrence assertion to expect false when removing null. These changes improve test clarity and reuse.
Added explicit overrides for common Deque operations (addFirst, addLast, removeFirst, removeLast, removeFirstOccurrence, push, pop, offer, poll, peek) in TestDeque that simply delegate to the superclass. This clarifies the class API and ensures these methods are available/overridable for testing or further extension without changing behavior.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request introduces several important updates to the build configuration, dependencies, and code organization for the Microsphere annotation processor and related modules. The main focus is on modernizing the build workflow, refactoring dependencies, and improving code modularity and maintainability.
Build and Workflow Modernization:
actions/checkoutandactions/setup-java, and switched the Maven build command to use the Maven Wrapper (./mvnw). This ensures better compatibility and reproducibility across environments. [1] [2]Dependency and Module Refactoring:
microsphere-annotation-processor/pom.xml, includingmicrosphere-lang-model,microsphere-jdk-tools, andmicrosphere-java-test, and removed redundant property definitions. This enhances functionality and testability. [1] [2] [3] [4]microsphere-java-annotations, establishing a dedicated location for annotation-related code and tests.Sinceannotation frommicrosphere-java-coreto the newmicrosphere-java-annotationsmodule, removing unused imports and references. [1] [2] [3]ConfigurationPropertyTestto match the new module structure.Codebase Modularization and Cleanup:
microsphere.lang.model.utilpackage, improving code clarity and modularity. [1] [2] [3] [4] [5] [6] [7]AbstractAnnotationProcessingTestand modernized lifecycle hooks to use JUnit 5's extension context and reflective invocation context for better test isolation and flexibility. [1] [2] [3] [4] [5] [6]These changes collectively improve maintainability, modularity, and reliability of the build and testing process for Microsphere annotation processing.