Skip to content

Commit 830f9ca

Browse files
authored
feat: permit @setting in ConfigurationExtension (#229)
* feat: permit @setting in ConfigurationExtension * dependencies
1 parent 46a48d0 commit 830f9ca

File tree

7 files changed

+47
-20
lines changed

7 files changed

+47
-20
lines changed

DEPENDENCIES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ maven/mavencentral/commons-collections/commons-collections/3.2.2, Apache-2.0, ap
4646
maven/mavencentral/commons-io/commons-io/2.4, Apache-1.1, approved, CQ9218
4747
maven/mavencentral/commons-io/commons-io/2.6, Apache-2.0, approved, CQ19090
4848
maven/mavencentral/commons-logging/commons-logging/1.2, Apache-2.0, approved, CQ10162
49+
maven/mavencentral/dev.failsafe/failsafe/3.3.2, Apache-2.0, approved, #9268
4950
maven/mavencentral/gradle.plugin.org.gradle.crypto/checksum/1.4.0, Apache-2.0, approved, #9667
5051
maven/mavencentral/info.picocli/picocli/4.7.5, Apache-2.0, approved, #4365
5152
maven/mavencentral/io.github.gradle-nexus/publish-plugin/1.3.0, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause AND CPL-1.0 AND LGPL-2.1-only AND LGPL-2.1-or-later AND MIT AND LicenseRef-Permission-Notice), approved, #10359
53+
maven/mavencentral/io.opentelemetry/opentelemetry-api/1.32.0, Apache-2.0, approved, #11682
54+
maven/mavencentral/io.opentelemetry/opentelemetry-context/1.32.0, Apache-2.0, approved, #11683
5255
maven/mavencentral/io.swagger.core.v3/swagger-annotations/2.1.5, Apache-2.0, approved, clearlydefined
5356
maven/mavencentral/io.swagger.core.v3/swagger-core/2.1.5, Apache-2.0, approved, clearlydefined
5457
maven/mavencentral/io.swagger.core.v3/swagger-gradle-plugin/2.2.15, Apache-2.0 AND MIT, approved, #10356
@@ -110,6 +113,8 @@ maven/mavencentral/org.codehaus.plexus/plexus-container-default/2.1.0, Apache-2.
110113
maven/mavencentral/org.codehaus.plexus/plexus-utils/3.1.1, , approved, CQ16492
111114
maven/mavencentral/org.codehaus.plexus/plexus-utils/3.3.0, , approved, CQ21066
112115
maven/mavencentral/org.eclipse.edc/autodoc-processor/0.5.2-SNAPSHOT, Apache-2.0, approved, technology.edc
116+
maven/mavencentral/org.eclipse.edc/core-spi/0.5.2-SNAPSHOT, Apache-2.0, approved, technology.edc
117+
maven/mavencentral/org.eclipse.edc/policy-model/0.5.2-SNAPSHOT, Apache-2.0, approved, technology.edc
113118
maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.5.2-SNAPSHOT, Apache-2.0, approved, technology.edc
114119
maven/mavencentral/org.glassfish.web/javax.el/2.2.6, CDDL-1.0 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, #1654
115120
maven/mavencentral/org.hibernate.validator/hibernate-validator-annotation-processor/6.0.2.Final, Apache-2.0 AND LicenseRef-Public-Domain, approved, CQ20221

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ mockito = "5.11.0"
1414
assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" }
1515
checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" }
1616
edc-runtime-metamodel = { module = "org.eclipse.edc:runtime-metamodel", version.ref = "edc" }
17+
edc-core-spi = { module = "org.eclipse.edc:core-spi", version.ref = "edc" }
1718
jackson-annotations = { module = "com.fasterxml.jackson.core:jackson-annotations", version.ref = "jackson" }
1819
jackson-core = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jackson" }
1920
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }

plugins/autodoc/autodoc-processor/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ plugins {
1717

1818
dependencies {
1919
api(libs.edc.runtime.metamodel)
20+
21+
testImplementation(libs.edc.core.spi)
2022
}

plugins/autodoc/autodoc-processor/src/main/java/org/eclipse/edc/plugins/autodoc/core/processor/introspection/ModuleIntrospector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
*/
4747
public class ModuleIntrospector {
4848
private static final String SERVICE_EXTENSION_NAME = "org.eclipse.edc.spi.system.ServiceExtension";
49+
private static final String SYSTEM_EXTENSION_NAME = "org.eclipse.edc.spi.system.SystemExtension";
4950
private final Elements elementUtils;
5051
private final Types typeUtils;
5152
private final ProcessingEnvironment processingEnv;
@@ -56,7 +57,6 @@ public ModuleIntrospector(ProcessingEnvironment processingEnv) {
5657
this.typeUtils = processingEnv.getTypeUtils();
5758
}
5859

59-
6060
public List<String> getCategories(RoundEnvironment environment) {
6161
var extensionElement = environment.getElementsAnnotatedWith(Spi.class).iterator().next();
6262
return attributeStringValues("categories", mirrorFor(Spi.class, extensionElement), elementUtils);
@@ -96,7 +96,7 @@ public Set<Element> getExtensionElements(RoundEnvironment environment) {
9696
var settingsSymbols = environment.getElementsAnnotatedWith(Setting.class).stream()
9797
.peek(setting -> {
9898
var enclosingElement = setting.getEnclosingElement().asType();
99-
var serviceExtensionType = typeUtils.erasure(elementUtils.getTypeElement(SERVICE_EXTENSION_NAME).asType());
99+
var serviceExtensionType = typeUtils.erasure(elementUtils.getTypeElement(SYSTEM_EXTENSION_NAME).asType());
100100
if (!typeUtils.isAssignable(enclosingElement, serviceExtensionType)) {
101101
var message = "@Setting annotation must be used inside a ServiceExtension implementation, the " +
102102
"ones defined in %s will be excluded from the autodoc manifest".formatted(enclosingElement);

plugins/autodoc/autodoc-processor/src/test/java/org/eclipse/edc/plugins/autodoc/core/processor/EdcModuleProcessorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ void shouldFail_whenSettingIsDefinedInClassNotExtension() {
265265
});
266266
}
267267

268+
@Test
269+
void shouldPass_whenSettingIsDefinedInExtensionSubclass() {
270+
var task = createTask("test/ConfigurationExtensionWithSetting.java");
271+
272+
assertThat(task.call()).isTrue();
273+
}
274+
268275
private JavaCompiler.@NotNull CompilationTask createTask(String classPath) {
269276
try {
270277
var classes = getFiles(classPath);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.plugins.autodoc.core.processor.test;
16+
17+
import org.eclipse.edc.runtime.metamodel.annotation.Setting;
18+
import org.eclipse.edc.spi.system.ConfigurationExtension;
19+
import org.eclipse.edc.spi.system.configuration.Config;
20+
21+
public class ConfigurationExtensionWithSetting implements ConfigurationExtension {
22+
23+
@Setting("Valid because this is an extension of ServiceExtension")
24+
private static final String VALID_SETTING = "any";
25+
26+
@Override
27+
public Config getConfig() {
28+
return null;
29+
}
30+
}

plugins/autodoc/autodoc-processor/src/test/java/org/eclipse/edc/spi/system/ServiceExtension.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)