-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Generate configuration parameters overview #5932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
827df2b
ed2e1ee
14ffed5
63dd21b
578bdca
2d7547d
6bc410b
e06d4c1
ccea87e
fd1baf1
3295a99
3b5624f
314e8fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| plugins { | ||
| id("junitbuild.java-library-conventions") | ||
| } | ||
|
|
||
| description = "JUnit Platform Configuration API" | ||
|
|
||
| dependencies { | ||
| api(platform(projects.junitBom)) | ||
| api(projects.junitPlatformCommons) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it need that?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, but the way OSGI is setup makes it a requirement for every module. |
||
|
|
||
| compileOnlyApi(libs.apiguardian) | ||
| compileOnlyApi(libs.jspecify) | ||
| } | ||
|
|
||
| backwardCompatibilityChecks { | ||
| enabled = false // not yet released | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * Copyright 2015-2026 the original author or authors. | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License v2.0 which | ||
| * accompanies this distribution and is available at | ||
| * | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| */ | ||
|
|
||
| module org.junit.platform.configuration.api { | ||
| requires static transitive org.jspecify; | ||
| requires static transitive org.apiguardian.api; | ||
|
|
||
| exports org.junit.platform.configuration.api; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * Copyright 2026 the original author or authors. | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License v2.0 which | ||
| * accompanies this distribution and is available at | ||
| * | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| */ | ||
|
|
||
| package org.junit.platform.configuration.api; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| import org.apiguardian.api.API; | ||
|
|
||
| @API(status = API.Status.EXPERIMENTAL) | ||
| @Retention(RetentionPolicy.SOURCE) | ||
| @Target(ElementType.FIELD) | ||
| public @interface ConfigurationProperty { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Copyright 2012 the original author or authors. | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License v2.0 which | ||
| * accompanies this distribution and is available at | ||
| * | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| */ | ||
|
|
||
| @NullMarked | ||
| package org.junit.platform.configuration.api; | ||
|
|
||
| import org.jspecify.annotations.NullMarked; |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should build this as a fat/shadowed jar to make it easy to put it on the annotation processor classpath. No need to do that now, but let's discuss it. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| plugins { | ||
| id("junitbuild.java-library-conventions") | ||
| } | ||
|
|
||
| description = "JUnit Platform Configuration Processor" | ||
|
|
||
| dependencies { | ||
| api(platform(projects.junitBom)) | ||
| api(projects.junitPlatformConfigurationApi) | ||
| api(projects.junitPlatformCommons) | ||
|
|
||
| compileOnlyApi(libs.apiguardian) | ||
| compileOnlyApi(libs.jspecify) | ||
| } | ||
|
|
||
| backwardCompatibilityChecks { | ||
| enabled = false // not yet released | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Copyright 2015-2026 the original author or authors. | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License v2.0 which | ||
| * accompanies this distribution and is available at | ||
| * | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| */ | ||
|
|
||
| module org.junit.platform.configuration.processor { | ||
| requires static transitive org.jspecify; | ||
| requires static transitive org.apiguardian.api; | ||
|
|
||
| requires java.compiler; | ||
| requires org.junit.platform.configuration.api; | ||
|
|
||
| provides javax.annotation.processing.Processor with org.junit.platform.configuration.processor.ConfigurationMetadataAnnotationProcessor; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright 2026 the original author or authors. | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License v2.0 which | ||
| * accompanies this distribution and is available at | ||
| * | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| */ | ||
|
|
||
| package org.junit.platform.configuration.processor; | ||
|
|
||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.Set; | ||
|
|
||
| import javax.annotation.processing.AbstractProcessor; | ||
| import javax.annotation.processing.ProcessingEnvironment; | ||
| import javax.annotation.processing.RoundEnvironment; | ||
| import javax.annotation.processing.SupportedAnnotationTypes; | ||
| import javax.annotation.processing.SupportedSourceVersion; | ||
| import javax.lang.model.SourceVersion; | ||
| import javax.lang.model.element.TypeElement; | ||
| import javax.tools.StandardLocation; | ||
|
|
||
| import org.apiguardian.api.API; | ||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| @API(status = API.Status.EXPERIMENTAL) | ||
| @SupportedSourceVersion(SourceVersion.RELEASE_17) | ||
| @SupportedAnnotationTypes("org.junit.platform.configuration.api.ConfigurationProperty") | ||
| public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor { | ||
| private static final String METADATA_PATH = "META-INF/junit-platform-configuration-metadata.json"; | ||
| private @Nullable ProcessingEnvironment environment; | ||
|
|
||
| @Override | ||
| public synchronized void init(ProcessingEnvironment environment) { | ||
| super.init(environment); | ||
| this.environment = environment; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { | ||
| if (roundEnv.processingOver()) { | ||
| try { | ||
| var resource = requireNonNull(environment).getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", | ||
| METADATA_PATH); | ||
| try (var out = resource.openOutputStream()) { | ||
| out.write("{}".getBytes(StandardCharsets.UTF_8)); | ||
| } | ||
| } | ||
| catch (Exception ex) { | ||
| throw new IllegalStateException("Failed to write metadata", ex); | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Copyright 2012 the original author or authors. | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License v2.0 which | ||
| * accompanies this distribution and is available at | ||
| * | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| */ | ||
|
|
||
| @NullMarked | ||
| package org.junit.platform.configuration.processor; | ||
|
|
||
| import org.jspecify.annotations.NullMarked; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| org.junit.platform.configuration.processor.ConfigurationMetadataAnnotationProcessor,aggregating |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| org.junit.platform.configuration.processor.ConfigurationMetadataAnnotationProcessor |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| org.junit.platform.configuration.api@${version} jar:file:.+/junit-platform-configuration-api-\d.+\.jar..module-info\.class | ||
| exports org.junit.platform.configuration.api | ||
| requires java.base mandated | ||
| requires org.apiguardian.api static transitive | ||
| requires org.jspecify static transitive |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| org.junit.platform.configuration.processor@${version} jar:file:.+/junit-platform-configuration-processor-\d.+\.jar..module-info\.class | ||
| requires java.base mandated | ||
| requires java.compiler | ||
| requires org.apiguardian.api static transitive | ||
| requires org.jspecify static transitive | ||
| requires org.junit.platform.configuration.api | ||
| provides javax.annotation.processing.Processor with org.junit.platform.configuration.processor.ConfigurationMetadataAnnotationProcessor | ||
| contains org.junit.platform.configuration.processor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What warnings does this emit without
-processing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complain about all present annotations that weren't claimed by a processor.
Similar too:
https://stackoverflow.com/questions/69439506/no-processor-claimed-any-of-these-annotations