Skip to content

Commit

Permalink
fix: use project version as default annotationProcessor version (#255)
Browse files Browse the repository at this point in the history
* fix: use project version as default annotationProcessor version

* dependencies
  • Loading branch information
ndr-brt authored Aug 20, 2024
1 parent 0d4e625 commit 1dbf5ea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 68 deletions.
3 changes: 1 addition & 2 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ maven/mavencentral/org.codehaus.plexus/plexus-component-annotations/2.1.0, Apach
maven/mavencentral/org.codehaus.plexus/plexus-container-default/2.1.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.codehaus.plexus/plexus-utils/3.1.1, , approved, CQ16492
maven/mavencentral/org.codehaus.plexus/plexus-utils/3.3.0, , approved, CQ21066
maven/mavencentral/org.eclipse.edc/autodoc-processor/+, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/autodoc-processor/0.8.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot-spi/0.8.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/core-spi/0.8.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-model/0.8.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.8.2-20240819-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.8.2-SNAPSHOT, Apache-2.0, approved, technology.edc
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
maven/mavencentral/org.hibernate.validator/hibernate-validator-annotation-processor/6.0.2.Final, Apache-2.0 AND LicenseRef-Public-Domain, approved, CQ20221
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.gradle.api.artifacts.DependencyResolutionListener;
import org.gradle.api.artifacts.ResolvableDependencies;
import org.gradle.api.tasks.compile.JavaCompile;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand All @@ -42,17 +43,7 @@ class AutodocDependencyInjector implements DependencyResolutionListener {

@Override
public void beforeResolve(ResolvableDependencies dependencies) {
var processorVersion = extension.getProcessorVersion();

var artifact = DEPENDENCY_NAME;
if (processorVersion.isPresent()) {
var version = processorVersion.get();
artifact += ":" + version;
project.getLogger().debug("{}: use configured version from AutodocExtension (override) [{}]", project.getName(), version);
} else {
artifact += ":+";
project.getLogger().info("No explicit configuration value for the annotationProcessor version was found. Current one will be used");
}
var artifact = DEPENDENCY_NAME + ":" + getProcessorVersion();

if (addDependency(project, artifact)) {
var task = project.getTasks().findByName("compileJava");
Expand All @@ -72,6 +63,20 @@ public void afterResolve(ResolvableDependencies dependencies) {

}

private @NotNull String getProcessorVersion() {
var processorVersion = extension.getProcessorVersion();

if (processorVersion.isPresent()) {
var version = processorVersion.get();
project.getLogger().debug("{}: use configured version from AutodocExtension (override) [{}]", project.getName(), version);
return version;
} else {
var version = project.getVersion().toString();
project.getLogger().info("No explicit configuration value for the annotationProcessor version was found. Project version {} will be used", version);
return version;
}
}

/**
* Adds an {@code annotationProcessor} dependency to the given project.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,14 @@
* Root configuration resource for the EDC Build plugin
*/
public abstract class BuildExtension {
private final VersionsExtension versions;
private final MavenPomExtension pom;
private final SwaggerGeneratorExtension swagger;

public BuildExtension(ObjectFactory objectFactory) {
versions = objectFactory.newInstance(VersionsExtension.class);
pom = objectFactory.newInstance(MavenPomExtension.class);
swagger = objectFactory.newInstance(SwaggerGeneratorExtension.class);
}


public void versions(Action<? super VersionsExtension> action) {
action.execute(versions);
}

public void pom(Action<? super MavenPomExtension> action) {
action.execute(pom);
}
Expand All @@ -47,10 +40,6 @@ public void swagger(Action<? super SwaggerGeneratorExtension> action) {
action.execute(swagger);
}

public VersionsExtension getVersions() {
return versions;
}

public MavenPomExtension getPom() {
return pom;
}
Expand Down

This file was deleted.

0 comments on commit 1dbf5ea

Please sign in to comment.