Skip to content

Commit fb22b8b

Browse files
committed
feat: add MetadataPropertiesProvider foundation
1 parent fe22946 commit fb22b8b

File tree

5 files changed

+110
-3
lines changed

5 files changed

+110
-3
lines changed

core/flamingock-core-commons/src/main/java/io/flamingock/internal/common/core/metadata/FlamingockMetadata.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,24 @@
1717

1818
import io.flamingock.internal.common.core.preview.PreviewPipeline;
1919

20+
import java.util.HashMap;
21+
import java.util.Map;
22+
2023
public class FlamingockMetadata {
2124

2225
private PreviewPipeline pipeline;
2326
private String setup;
2427
private String configFile;
28+
private Map<String, String> properties;
2529

2630
public FlamingockMetadata() {
2731
}
2832

29-
public FlamingockMetadata(PreviewPipeline pipeline, String setup, String configFile) {
33+
public FlamingockMetadata(PreviewPipeline pipeline, String setup, String configFile, Map<String, String> properties) {
3034
this.pipeline = pipeline;
3135
this.setup = setup;
3236
this.configFile = configFile;
37+
this.properties = properties != null ? properties : new HashMap<>();
3338
}
3439

3540
public PreviewPipeline getPipeline() {
@@ -56,11 +61,28 @@ public void setPipelineFile(String configFile) {
5661
this.configFile = configFile;
5762
}
5863

64+
public String getConfigFile() {
65+
return configFile;
66+
}
67+
68+
public void setConfigFile(String configFile) {
69+
this.configFile = configFile;
70+
}
71+
72+
public Map<String, String> getProperties() {
73+
return properties;
74+
}
75+
76+
public void setProperties(Map<String, String> properties) {
77+
this.properties = properties;
78+
}
79+
5980
@Override
6081
public String toString() {
6182
return "FlamingockMetadata{" + "pipeline=" + pipeline +
6283
", setup='" + setup + '\'' +
6384
", configFile='" + configFile + '\'' +
85+
", properties=" + properties +
6486
'}';
6587
}
6688
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2025 Flamingock (https://www.flamingock.io)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.flamingock.internal.common.core.metadata;
17+
18+
import io.flamingock.internal.common.core.util.LoggerPreProcessor;
19+
20+
import javax.annotation.processing.RoundEnvironment;
21+
import java.util.Map;
22+
23+
public interface MetadataPropertiesProvider {
24+
Map<String, String> getProperties(RoundEnvironment roundEnv, LoggerPreProcessor logger);
25+
}

core/flamingock-processor/src/main/java/io/flamingock/core/processor/FlamingockAnnotationProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.flamingock.api.annotations.EnableFlamingock;
2121
import io.flamingock.api.annotations.Stage;
2222
import io.flamingock.core.processor.util.AnnotationFinder;
23+
import io.flamingock.core.processor.util.MetadataPropertiesLoader;
2324
import io.flamingock.core.processor.util.PathResolver;
2425
import io.flamingock.core.processor.util.ProjectRootDetector;
2526
import io.flamingock.internal.common.core.preview.CodePreviewChange;
@@ -212,7 +213,8 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
212213
Serializer serializer = new Serializer(processingEnv, logger);
213214
String setup = flamingockAnnotation.setup().toString();
214215
String configFile = flamingockAnnotation.configFile();
215-
FlamingockMetadata flamingockMetadata = new FlamingockMetadata(pipeline, setup, configFile);
216+
Map<String, String> properties = MetadataPropertiesLoader.loadAllProperties(roundEnv, logger);
217+
FlamingockMetadata flamingockMetadata = new FlamingockMetadata(pipeline, setup, configFile, properties);
216218
serializer.serializeFullPipeline(flamingockMetadata);
217219

218220
// Generate summary - count all changes from the final pipeline (code-based + template-based)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2025 Flamingock (https://www.flamingock.io)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.flamingock.core.processor.util;
17+
18+
import io.flamingock.internal.common.core.metadata.MetadataPropertiesProvider;
19+
import io.flamingock.internal.common.core.util.LoggerPreProcessor;
20+
21+
import java.util.LinkedHashMap;
22+
import java.util.Map;
23+
import java.util.Objects;
24+
import java.util.ServiceLoader;
25+
import javax.annotation.processing.RoundEnvironment;
26+
public final class MetadataPropertiesLoader {
27+
public static Map<String, String> loadAllProperties(RoundEnvironment roundEnv, LoggerPreProcessor logger) {
28+
Map<String, String> result = new LinkedHashMap<>();
29+
30+
ServiceLoader<MetadataPropertiesProvider> loader =
31+
ServiceLoader.load(MetadataPropertiesProvider.class, MetadataPropertiesLoader.class.getClassLoader());
32+
33+
for (MetadataPropertiesProvider provider : loader) {
34+
Map<String, String> props = provider.getProperties(roundEnv, logger);
35+
if (props == null || props.isEmpty()) {
36+
continue;
37+
}
38+
39+
for (Map.Entry<String, String> entry : props.entrySet()) {
40+
String key = entry.getKey();
41+
String value = entry.getValue();
42+
43+
String previous = result.put(key, value);
44+
if (previous != null && !Objects.equals(previous, value)) {
45+
String message = String.format("%s overrides key '%s' "
46+
+ "previous value='%s' new value='%s'",
47+
provider.getClass().getName(),
48+
key,
49+
previous,
50+
value);
51+
logger.warn(message);
52+
}
53+
}
54+
}
55+
56+
return result;
57+
}
58+
}

platform-plugins/flamingock-springboot-integration/src/test/java/io/flamingock/springboot/FlamingockAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void runnerBeanRegisteredWhenSetupAbsent(@TempDir Path dir) throws IOException {
9696
void runnerBeanNotRegisteredWhenSetupBuilder() throws IOException {
9797
// replace the supplier so the Condition "sees" BUILDER
9898
OnFlamingockEnabledCondition.setMetadataSupplier(
99-
() -> Optional.of(new FlamingockMetadata(null, "BUILDER", null))
99+
() -> Optional.of(new FlamingockMetadata(null, "BUILDER", null, null))
100100
);
101101

102102
contextEmpty().run(ctx -> assertThat(ctx).doesNotHaveBean("flamingock-runner"));

0 commit comments

Comments
 (0)