Skip to content

Commit 32b402d

Browse files
authored
Merge pull request #248 from microsphere-projects/dev
Release 0.1.8
2 parents 711b085 + 9f78de2 commit 32b402d

372 files changed

Lines changed: 11937 additions & 4066 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/maven-build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ jobs:
2222
java: [ '8', '11' , '17' , '21' , '25' ]
2323
steps:
2424
- name: Checkout Source
25-
uses: actions/checkout@v4
25+
uses: actions/checkout@v5
2626

2727
- name: Setup JDK ${{ matrix.Java }}
28-
uses: actions/setup-java@v4
28+
uses: actions/setup-java@v5
2929
with:
3030
distribution: 'temurin'
3131
java-version: ${{ matrix.java }}
32-
cache: maven
3332

3433
- name: Build with Maven
35-
run: mvn
34+
run: ./mvnw
3635
--batch-mode
3736
--update-snapshots
3837
--file pom.xml
3938
-Drevision=0.0.1-SNAPSHOT
39+
-Dsurefire.useSystemClassLoader=false
4040
test
4141
--activate-profiles test,coverage
4242

.github/workflows/maven-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
if: ${{ inputs.revision }}
2525
steps:
2626
- name: Checkout Source
27-
uses: actions/checkout@v4
27+
uses: actions/checkout@v5
2828

2929
- name: Setup Maven Central Repository
30-
uses: actions/setup-java@v4
30+
uses: actions/setup-java@v5
3131
with:
3232
java-version: '11'
3333
distribution: 'temurin'

.mvn/wrapper/maven-wrapper.jar

-58.5 KB
Binary file not shown.
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
# Copyright 2013-2023 the original author or authors.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# https://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
16-
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://maven.aliyun.com/repository/public/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,30 @@ frameworks like Spring, making it a versatile addition to any Java developer's t
3737
- JMX
3838
- Versioning
3939
- Annotation processing
40+
- Tools
41+
- Testing
4042

4143
## Modules
4244

4345
The framework is organized into several key modules:
4446

45-
Module | Purpose
46-
----------------------------------|-------------------------------------------------------------------------------------------------
47-
microsphere-java-core | Provides core utilities across various domains like annotations, collections, concurrency, etc.
48-
microsphere-annotation-processor | Offers annotation processing capabilities for compile-time code generation
49-
microsphere-java-dependencies | Manages dependency versions across the project
50-
microsphere-java-parent | Parent POM with shared configurations
47+
Module | Purpose
48+
----------------------------------|-----------------------------------------------------------------------------------------------------
49+
microsphere-java-annotations | Provides the common annotations for Microsphere Java projects.
50+
microsphere-java-core | Provides the core utilities across various domains like annotations, collections, concurrency, etc.
51+
microsphere-java-model | Provides the components and utilities across Java Language Model API.
52+
microsphere-jdk-tools | Offers the components for Java tools.
53+
microsphere-annotation-processor | Offers annotation processing capabilities for compile-time code generation.
54+
microsphere-java-test | Provides the models and components for Java testing.
55+
microsphere-java-dependencies | Manages dependency versions across the project.
56+
microsphere-java-parent | Parent POM with shared configurations.
5157

5258
## Getting Started
5359

5460
The easiest way to get started is by adding the Microsphere Java BOM (Bill of Materials) to your project's pom.xml:
5561

5662
```xml
63+
5764
<dependencyManagement>
5865
<dependencies>
5966
...
@@ -73,6 +80,7 @@ The easiest way to get started is by adding the Microsphere Java BOM (Bill of Ma
7380
Then add the specific modules you need:
7481

7582
```xml
83+
7684
<dependencies>
7785
<!-- Core utilities -->
7886
<dependency>
@@ -159,8 +167,12 @@ We welcome your contributions! Please read [Code of Conduct](./CODE_OF_CONDUCT.m
159167

160168
### JavaDoc
161169

170+
- [microsphere-java-annotations](https://javadoc.io/doc/io.github.microsphere-projects/microsphere-java-annotations)
162171
- [microsphere-java-core](https://javadoc.io/doc/io.github.microsphere-projects/microsphere-java-core)
172+
- [microsphere-java-model](https://javadoc.io/doc/io.github.microsphere-projects/microsphere-java-model)
173+
- [microsphere-jdk-tools](https://javadoc.io/doc/io.github.microsphere-projects/microsphere-jdk-tools)
163174
- [microsphere-annotation-processor](https://javadoc.io/doc/io.github.microsphere-projects/microsphere-annotation-processor)
175+
- [microsphere-java-test](https://javadoc.io/doc/io.github.microsphere-projects/microsphere-java-test)
164176

165177
## License
166178

microsphere-annotation-processor/pom.xml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
<name>Microsphere :: Java :: Annotation Processor</name>
1919
<description>Microsphere Annotation Processor</description>
2020

21-
<properties>
22-
<javax.ws.rs.version>2.1</javax.ws.rs.version>
23-
<jaxws-api.version>2.3.1</jaxws-api.version>
24-
</properties>
25-
2621
<dependencies>
2722

2823
<!-- Microsphere Java Core -->
@@ -32,6 +27,13 @@
3227
<version>${revision}</version>
3328
</dependency>
3429

30+
<!-- Microsphere Language Model -->
31+
<dependency>
32+
<groupId>io.github.microsphere-projects</groupId>
33+
<artifactId>microsphere-lang-model</artifactId>
34+
<version>${revision}</version>
35+
</dependency>
36+
3537
<!-- Testing -->
3638
<dependency>
3739
<groupId>org.junit.jupiter</groupId>
@@ -45,6 +47,22 @@
4547
<scope>test</scope>
4648
</dependency>
4749

50+
<!-- Microsphere JDK Tools -->
51+
<dependency>
52+
<groupId>io.github.microsphere-projects</groupId>
53+
<artifactId>microsphere-jdk-tools</artifactId>
54+
<version>${revision}</version>
55+
<scope>test</scope>
56+
</dependency>
57+
58+
<!-- Microsphere Java Test -->
59+
<dependency>
60+
<groupId>io.github.microsphere-projects</groupId>
61+
<artifactId>microsphere-java-test</artifactId>
62+
<version>${revision}</version>
63+
<scope>test</scope>
64+
</dependency>
65+
4866
<!-- Logback -->
4967
<dependency>
5068
<groupId>ch.qos.logback</groupId>
@@ -56,15 +74,13 @@
5674
<dependency>
5775
<groupId>javax.ws.rs</groupId>
5876
<artifactId>javax.ws.rs-api</artifactId>
59-
<version>${javax.ws.rs.version}</version>
6077
<scope>test</scope>
6178
</dependency>
6279

6380
<!-- JAX-WS API-->
6481
<dependency>
6582
<groupId>javax.xml.ws</groupId>
6683
<artifactId>jaxws-api</artifactId>
67-
<version>${jaxws-api.version}</version>
6884
<scope>test</scope>
6985
</dependency>
7086

microsphere-annotation-processor/src/main/java/io/microsphere/annotation/processor/ConfigurationPropertyAnnotationProcessor.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package io.microsphere.annotation.processor;
1919

2020
import io.microsphere.annotation.ConfigurationProperty;
21-
import io.microsphere.annotation.processor.model.util.ConfigurationPropertyJSONElementVisitor;
21+
import io.microsphere.constants.ResourceConstants;
2222
import io.microsphere.json.JSONArray;
2323
import io.microsphere.metadata.ConfigurationPropertyGenerator;
2424

@@ -35,12 +35,12 @@
3535
import java.util.List;
3636
import java.util.Set;
3737

38-
import static io.microsphere.annotation.processor.model.util.ConfigurationPropertyJSONElementVisitor.CONFIGURATION_PROPERTY_ANNOTATION_CLASS_NAME;
39-
import static io.microsphere.annotation.processor.util.MessagerUtils.printNote;
38+
import static io.microsphere.annotation.processor.ConfigurationPropertyJSONElementVisitor.CONFIGURATION_PROPERTY_ANNOTATION_CLASS_NAME;
4039
import static io.microsphere.constants.ResourceConstants.CONFIGURATION_PROPERTY_METADATA_RESOURCE;
4140
import static io.microsphere.constants.SymbolConstants.COMMA_CHAR;
4241
import static io.microsphere.constants.SymbolConstants.LEFT_SQUARE_BRACKET_CHAR;
4342
import static io.microsphere.constants.SymbolConstants.RIGHT_SQUARE_BRACKET_CHAR;
43+
import static io.microsphere.lang.model.util.MessagerUtils.printNote;
4444
import static io.microsphere.metadata.ConfigurationPropertyLoader.loadAll;
4545
import static javax.lang.model.SourceVersion.latestSupported;
4646
import static javax.tools.StandardLocation.CLASS_OUTPUT;
@@ -62,7 +62,7 @@
6262
* </li>
6363
* <li>{@link #resolveMetadata(RoundEnvironment)} traverses all root elements to extract configuration property metadata.</li>
6464
* <li>{@link #writeMetadata()} writes the generated metadata into a JSON file under
65-
* {@value #CONFIGURATION_PROPERTY_METADATA_RESOURCE_NAME} using a writer.</li>
65+
* {@value ResourceConstants#CONFIGURATION_PROPERTY_METADATA_RESOURCE} using a writer.</li>
6666
* </ul>
6767
*
6868
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
@@ -106,24 +106,28 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
106106

107107
private void resolveMetadata(RoundEnvironment roundEnv) {
108108
Set<? extends Element> elements = roundEnv.getRootElements();
109-
if (!elements.isEmpty()) {
109+
resolveMetadata(elements);
110+
}
111+
112+
void resolveMetadata(Set<? extends Element> elements) {
113+
jsonBuilder.append(LEFT_SQUARE_BRACKET_CHAR);
110114

115+
// Resolve the content
116+
if (!elements.isEmpty()) {
111117
Iterator<? extends Element> iterator = elements.iterator();
112-
jsonBuilder.append(LEFT_SQUARE_BRACKET_CHAR);
113118
while (iterator.hasNext()) {
114119
Element element = iterator.next();
115120
element.accept(jsonElementVisitor, jsonBuilder);
116121
}
117-
118122
// append the JSON content generated by ConfigurationPropertyGenerator SPI
119123
appendGeneratedConfigurationPropertyJSON(jsonBuilder);
124+
}
120125

121-
int lastIndex = jsonBuilder.length() - 1;
122-
if (COMMA_CHAR == jsonBuilder.charAt(lastIndex)) {
123-
jsonBuilder.setCharAt(lastIndex, RIGHT_SQUARE_BRACKET_CHAR);
124-
} else {
125-
jsonBuilder.append(RIGHT_SQUARE_BRACKET_CHAR);
126-
}
126+
int lastIndex = jsonBuilder.length() - 1;
127+
if (COMMA_CHAR == jsonBuilder.charAt(lastIndex)) {
128+
jsonBuilder.setCharAt(lastIndex, RIGHT_SQUARE_BRACKET_CHAR);
129+
} else {
130+
jsonBuilder.append(RIGHT_SQUARE_BRACKET_CHAR);
127131
}
128132
}
129133

@@ -151,9 +155,12 @@ private void writeMetadata() {
151155
});
152156
}
153157

158+
String toJSON() {
159+
return jsonBuilder.toString();
160+
}
161+
154162
@Override
155163
public SourceVersion getSupportedSourceVersion() {
156164
return latestSupported();
157165
}
158166
}
159-

microsphere-annotation-processor/src/main/java/io/microsphere/annotation/processor/model/util/ConfigurationPropertyJSONElementVisitor.java renamed to microsphere-annotation-processor/src/main/java/io/microsphere/annotation/processor/ConfigurationPropertyJSONElementVisitor.java

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,31 @@
1515
* limitations under the License.
1616
*/
1717

18-
package io.microsphere.annotation.processor.model.util;
18+
package io.microsphere.annotation.processor;
1919

2020
import io.microsphere.annotation.ConfigurationProperty;
2121
import io.microsphere.beans.ConfigurationProperty.Metadata;
22+
import io.microsphere.lang.model.util.AnnotatedElementJSONElementVisitor;
2223
import io.microsphere.metadata.ConfigurationPropertyGenerator;
2324

2425
import javax.annotation.processing.ProcessingEnvironment;
2526
import javax.lang.model.element.AnnotationMirror;
2627
import javax.lang.model.element.AnnotationValue;
2728
import javax.lang.model.element.Element;
2829
import javax.lang.model.element.ExecutableElement;
30+
import javax.lang.model.element.TypeElement;
2931
import javax.lang.model.element.VariableElement;
3032
import javax.lang.model.type.TypeMirror;
3133
import java.util.List;
3234
import java.util.Map;
3335

34-
import static io.microsphere.annotation.processor.util.AnnotationUtils.getAnnotation;
35-
import static io.microsphere.annotation.processor.util.AnnotationUtils.getAttributeName;
36-
import static io.microsphere.annotation.processor.util.AnnotationUtils.getElementValues;
37-
import static io.microsphere.annotation.processor.util.AnnotationUtils.matchesDefaultAttributeValue;
38-
import static io.microsphere.annotation.processor.util.ClassUtils.getClassName;
39-
import static io.microsphere.annotation.processor.util.TypeUtils.getTypeName;
4036
import static io.microsphere.constants.SymbolConstants.COMMA_CHAR;
37+
import static io.microsphere.lang.model.util.AnnotationUtils.getAnnotation;
38+
import static io.microsphere.lang.model.util.AnnotationUtils.getAttributeName;
39+
import static io.microsphere.lang.model.util.AnnotationUtils.getElementValues;
40+
import static io.microsphere.lang.model.util.AnnotationUtils.matchesDefaultAttributeValue;
41+
import static io.microsphere.lang.model.util.ClassUtils.getClassName;
42+
import static io.microsphere.lang.model.util.TypeUtils.getTypeName;
4143
import static io.microsphere.util.ServiceLoaderUtils.loadFirstService;
4244
import static io.microsphere.util.StringUtils.isBlank;
4345

@@ -51,13 +53,13 @@
5153
* @see io.microsphere.beans.ConfigurationProperty
5254
* @since 1.0.0
5355
*/
54-
public class ConfigurationPropertyJSONElementVisitor extends AnnotatedElementJSONElementVisitor {
56+
class ConfigurationPropertyJSONElementVisitor extends AnnotatedElementJSONElementVisitor {
5557

56-
public static final String CONFIGURATION_PROPERTY_ANNOTATION_CLASS_NAME = "io.microsphere.annotation.ConfigurationProperty";
58+
static final String CONFIGURATION_PROPERTY_ANNOTATION_CLASS_NAME = "io.microsphere.annotation.ConfigurationProperty";
5759

5860
private final ConfigurationPropertyGenerator generator;
5961

60-
public ConfigurationPropertyJSONElementVisitor(ProcessingEnvironment processingEnv) {
62+
ConfigurationPropertyJSONElementVisitor(ProcessingEnvironment processingEnv) {
6163
super(processingEnv, CONFIGURATION_PROPERTY_ANNOTATION_CLASS_NAME);
6264
this.generator = loadFirstService(ConfigurationPropertyGenerator.class);
6365
}
@@ -87,8 +89,8 @@ public Boolean visitVariableAsField(VariableElement field, StringBuilder jsonBui
8789
} else if ("description".equals(attributeName)) {
8890
String description = resolveDescription(field, attributeMethod, annotationValue);
8991
configurationProperty.setDescription(description);
90-
} else if ("source".equals(attributeName)) {
91-
setSources(configurationProperty, annotationValue);
92+
} else {
93+
setSources(configurationProperty, attributeName, annotationValue);
9294
}
9395
}
9496
setDeclaredClass(configurationProperty, field);
@@ -102,6 +104,11 @@ public Boolean visitVariableAsField(VariableElement field, StringBuilder jsonBui
102104
return false;
103105
}
104106

107+
@Override
108+
protected boolean supportsType(TypeElement e) {
109+
return true;
110+
}
111+
105112
public ConfigurationPropertyGenerator getGenerator() {
106113
return generator;
107114
}
@@ -130,12 +137,14 @@ private String resolveStringValue(ExecutableElement attributeMethod, AnnotationV
130137
return (String) value;
131138
}
132139

133-
private void setSources(io.microsphere.beans.ConfigurationProperty configurationProperty, AnnotationValue annotationValue) {
134-
List<? extends AnnotationValue> sources = (List<? extends AnnotationValue>) annotationValue.getValue();
135-
Metadata metadata = configurationProperty.getMetadata();
136-
for (AnnotationValue source : sources) {
137-
String sourceValue = (String) source.getValue();
138-
metadata.getSources().add(sourceValue);
140+
void setSources(io.microsphere.beans.ConfigurationProperty configurationProperty, String attributeName, AnnotationValue annotationValue) {
141+
if ("source".equals(attributeName)) {
142+
List<? extends AnnotationValue> sources = (List<? extends AnnotationValue>) annotationValue.getValue();
143+
Metadata metadata = configurationProperty.getMetadata();
144+
for (AnnotationValue source : sources) {
145+
String sourceValue = (String) source.getValue();
146+
metadata.getSources().add(sourceValue);
147+
}
139148
}
140149
}
141150

@@ -149,5 +158,4 @@ private void setDeclaredField(io.microsphere.beans.ConfigurationProperty configu
149158
String declaredFieldName = field.getSimpleName().toString();
150159
configurationProperty.getMetadata().setDeclaredField(declaredFieldName);
151160
}
152-
153-
}
161+
}

microsphere-annotation-processor/src/main/java/io/microsphere/annotation/processor/FilerProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import javax.tools.JavaFileManager;
2525
import java.util.function.BiFunction;
2626

27-
import static io.microsphere.annotation.processor.util.MessagerUtils.printMandatoryWarning;
27+
import static io.microsphere.lang.model.util.MessagerUtils.printMandatoryWarning;
2828
import static io.microsphere.reflect.FieldUtils.getFieldValue;
2929

3030
/**

microsphere-annotation-processor/src/main/java/io/microsphere/annotation/processor/ResourceProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
import java.util.function.BiFunction;
3535
import java.util.function.Function;
3636

37-
import static io.microsphere.annotation.processor.util.MessagerUtils.printNote;
38-
import static io.microsphere.annotation.processor.util.MessagerUtils.printWarning;
37+
import static io.microsphere.lang.model.util.MessagerUtils.printNote;
38+
import static io.microsphere.lang.model.util.MessagerUtils.printWarning;
3939
import static io.microsphere.util.ExceptionUtils.wrap;
4040
import static java.util.Optional.empty;
4141
import static java.util.Optional.of;

0 commit comments

Comments
 (0)