This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new 4d982b392c3 CAMEL-18941: Handle AutoConfiguration.imports updates
4d982b392c3 is described below
commit 4d982b392c30e84fc49a48e881cfcdbc7aa1de30
Author: Croway <[email protected]>
AuthorDate: Thu Jan 8 12:25:50 2026 +0100
CAMEL-18941: Handle AutoConfiguration.imports updates
---
.../catalog/components/iec60870-client.json | 13 ++-
.../maven/SpringBootAutoConfigurationMojo.java | 102 +++++++++++++--------
2 files changed, 78 insertions(+), 37 deletions(-)
diff --git
a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/iec60870-client.json
b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/iec60870-client.json
index bdad4d5faa9..17e1da71463 100644
---
a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/iec60870-client.json
+++
b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/iec60870-client.json
@@ -33,7 +33,18 @@
"CamelIec60870Value": { "index": 0, "kind": "header", "displayName": "",
"group": "consumer", "label": "consumer", "required": false, "javaType":
"Object", "deprecated": false, "deprecationNote": "", "autowired": false,
"secret": false, "description": "The value", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_VALUE" },
"CamelIec60870Timestamp": { "index": 1, "kind": "header", "displayName":
"", "group": "consumer", "label": "consumer", "required": false, "javaType":
"long", "deprecated": false, "deprecationNote": "", "autowired": false,
"secret": false, "description": "The timestamp of the value", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_TIMESTAMP" },
"CamelIec60870Quality": { "index": 2, "kind": "header", "displayName": "",
"group": "consumer", "label": "consumer", "required": false, "javaType":
"org.eclipse.neoscada.protocol.iec60870.asdu.types.QualityInformation",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The quality information of the value", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_QUALITY" },
- "CamelIec60870Overflow": { "index": 3, "kind": "header", "displayName":
"", "group": "consumer", "label": "consumer", "required": false, "javaType":
"boolean", "deprecated": false, "deprecationNote": "", "autowired": false,
"secret": false, "description": "Is overflow", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_OVERFLOW" }
+ "CamelIec60870Overflow": { "index": 3, "kind": "header", "displayName":
"", "group": "consumer", "label": "consumer", "required": false, "javaType":
"boolean", "deprecated": false, "deprecationNote": "", "autowired": false,
"secret": false, "description": "Is overflow", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_OVERFLOW" },
+ "CamelIec60870ConnectionState": { "index": 4, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType":
"org.eclipse.neoscada.protocol.iec60870.client.AutoConnectClient.State",
"enum": [ "SLEEPING", "DISCONNECTED", "LOOKUP", "CONNECTING", "CONNECTED" ],
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The connection state (CONNECTED, DISCONNECTED, etc.)",
"constantName": "org.apache.ca [...]
+ "CamelIec60870ConnectionError": { "index": 5, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType": "Throwable", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "The connection state error
if any", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_CONNECTION_ERROR" },
+ "CamelIec60870ConnectionUptime": { "index": 6, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType": "long", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Connection uptime in milliseconds since
last connected", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_CONNECTION_UPTIME" },
+ "CamelIec60870CommandType": { "index": 7, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "deprecationNote": "", "autowired": false,
"secret": false, "description": "The command type: 'value' (default),
'interrogation', 'read', or 'status'", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_COMMAND_TYPE" },
+ "CamelIec60870AsduAddress": { "index": 8, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"org.eclipse.neoscada.protocol.iec60870.asdu.types.ASDUAddress", "deprecated":
false, "deprecationNote": "", "autowired": false, "secret": false,
"description": "The ASDU address for interrogation (optional, defaults to
broadcast)", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_ASDU_ADDRESS" },
+ "CamelIec60870Qoi": { "index": 9, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"short", "deprecated": false, "deprecationNote": "", "autowired": false,
"secret": false, "description": "The qualifier of interrogation: 20 (global) or
21-36 (groups 1-16)", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_QOI" },
+ "CamelIec60870QualityBlocked": { "index": 10, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Quality flag: Blocked (BL)",
"constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_QUALITY_BLOCKED" },
+ "CamelIec60870QualitySubstituted": { "index": 11, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Quality flag: Substituted (SB)",
"constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_QUALITY_SUBSTITUTED" },
+ "CamelIec60870QualityNotTopical": { "index": 12, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Quality flag: Not topical (NT)",
"constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_QUALITY_NOT_TOPICAL" },
+ "CamelIec60870QualityValid": { "index": 13, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Quality flag: Invalid (IV)",
"constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_QUALITY_VALID" },
+ "CamelIec60870CauseOfTransmission": { "index": 14, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType":
"org.eclipse.neoscada.protocol.iec60870.asdu.types.CauseOfTransmission",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The cause of transmission", "constantName":
"org.apache.camel.component.iec60870.Constants#IEC60870_CAUSE_OF_TRANSMISSION" }
},
"properties": {
"uriPath": { "index": 0, "kind": "path", "displayName": "Uri Path",
"group": "common", "label": "", "required": true, "type": "object", "javaType":
"org.apache.camel.component.iec60870.ObjectAddress", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
object information address" },
diff --git
a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
index 1d1c0c85199..fc576b9d16b 100644
---
a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
+++
b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
@@ -1903,52 +1903,82 @@ public class SpringBootAutoConfigurationMojo extends
AbstractSpringBootGenerator
deleteFileOnMainArtifact(target);
- if (target.exists()) {
- try {
- // is the auto configuration already in the file
- boolean found = false;
+ try {
+ // Use LinkedHashSet to preserve insertion order and avoid
duplicates
+ Set<String> allEntries = new LinkedHashSet<>();
+ String header = null;
+
+ // Read and preserve existing entries if file exists
+ if (target.exists()) {
List<String> lines = Files.readAllLines(target.toPath(),
StandardCharsets.UTF_8);
+ StringBuilder headerBuilder = new StringBuilder();
+ boolean inHeader = true;
+
for (String line : lines) {
- if (line.contains(name)) {
- found = true;
- break;
+ String trimmedLine = line.trim();
+
+ // Identify header (lines starting with ## or empty lines
at the beginning)
+ if (inHeader && (trimmedLine.startsWith("##") ||
trimmedLine.isEmpty())) {
+ headerBuilder.append(line).append("\n");
+ } else {
+ inHeader = false;
+ // Add only non-empty lines that are not comments
+ if (!trimmedLine.isEmpty() &&
!trimmedLine.startsWith("#")) {
+ allEntries.add(trimmedLine);
+ }
}
}
+
+ if (headerBuilder.length() > 0) {
+ header = headerBuilder.toString();
+ }
+ }
+
+ // Add new entry if it doesn't exist
+ boolean isNew = allEntries.add(lineToAdd);
+ if (isNew) {
+ getLog().info("Added new AutoConfiguration entry: " +
lineToAdd);
+ } else {
+ getLog().debug("AutoConfiguration entry already exists: " +
lineToAdd);
+ }
+
+ // Only proceed with file write if there are changes
+ if (!isNew && target.exists()) {
+ getLog().debug("No changes to existing file: " + target);
+ return;
+ }
- if (found) {
- getLog().debug("No changes to existing file: " + target);
- } else {
- lines.add(lineToAdd);
-
- StringBuilder code = new StringBuilder();
- for (String line : lines) {
- code.append(line).append("\n");
+ // Load header from template if not found in existing file
+ if (header == null) {
+ try (InputStream is =
getClass().getClassLoader().getResourceAsStream("license-header.txt")) {
+ if (is != null) {
+ header = PackageHelper.loadText(is);
}
-
- // update
- FileUtils.write(target, code.toString(),
StandardCharsets.UTF_8, false);
- getLog().info("Updated existing file: " + target);
}
- } catch (Exception e) {
- throw new MojoFailureException("IOError with file " + target,
e);
}
- } else {
- // create new file
- try (InputStream is =
getClass().getClassLoader().getResourceAsStream("license-header.txt")) {
- String header = PackageHelper.loadText(is);
- String code = lineToAdd;
- // add empty new line after header
- code = header + "\n" + code;
- if (getLog().isDebugEnabled()) {
- getLog().debug("Source code generated:\n" + code);
- }
- FileUtils.write(target, code, StandardCharsets.UTF_8);
- getLog().info("Created file: " + target);
- is.close();
- } catch (Exception e) {
- throw new MojoFailureException("IOError with file " + target,
e);
+ // Fallback if header is still null
+ if (header == null || header.isEmpty()) {
+ throw new MojoFailureException("Could not load license header
template (license-header.txt not found in classpath)");
+ }
+
+ // Build final content
+ StringBuilder content = new StringBuilder(header);
+ if (!header.endsWith("\n")) {
+ content.append("\n");
+ }
+
+ // Write all entries (preserve insertion order)
+ for (String entry : allEntries) {
+ content.append(entry).append("\n");
}
+
+ // Write file
+ FileUtils.write(target, content.toString(),
StandardCharsets.UTF_8, false);
+ getLog().info("Updated " + target + " with " + allEntries.size() +
" AutoConfiguration entries");
+
+ } catch (Exception e) {
+ throw new MojoFailureException("Error updating
AutoConfiguration.imports file: " + target, e);
}
}