Skip to content

Commit 4310eb8

Browse files
authored
feat: make edc-build register printClasspath plugin (#232)
1 parent c63ddb5 commit 4310eb8

File tree

4 files changed

+70
-2
lines changed

4 files changed

+70
-2
lines changed

plugins/edc-build/src/main/java/org/eclipse/edc/plugins/edcbuild/EdcBuildPlugin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.mavenPublication;
3131
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.mavenPublishing;
3232
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.nexusPublishing;
33+
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.printClasspath;
3334
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.repositories;
3435
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.rootBuildScript;
3536
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.signing;
@@ -74,7 +75,8 @@ public void apply(Project target) {
7475
allDependencies(),
7576
tests(),
7677
jar(),
77-
swagger()
78+
swagger(),
79+
printClasspath()
7880
).forEach(c -> c.apply(project));
7981
});
8082

plugins/edc-build/src/main/java/org/eclipse/edc/plugins/edcbuild/conventions/Conventions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public static EdcConvention checkstyle() {
2323
return new CheckstyleConvention();
2424
}
2525

26-
2726
public static EdcConvention mavenPublishing() {
2827
return new MavenPublishingConvention();
2928
}
@@ -87,4 +86,8 @@ public static EdcConvention openApiMerger() {
8786
public static EdcConvention mavenPublication() {
8887
return new MavenPublicationConvention();
8988
}
89+
90+
public static EdcConvention printClasspath() {
91+
return new PrintClasspathConvention();
92+
}
9093
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.edcbuild.conventions;
16+
17+
import org.eclipse.edc.plugins.edcbuild.tasks.PrintClasspathTask;
18+
import org.gradle.api.Project;
19+
20+
public class PrintClasspathConvention implements EdcConvention {
21+
@Override
22+
public void apply(Project target) {
23+
target.getTasks().register("printClasspath", PrintClasspathTask.class)
24+
.configure(t -> t.dependsOn("compileJava"));
25+
}
26+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.edcbuild.tasks;
16+
17+
import org.gradle.api.DefaultTask;
18+
import org.gradle.api.plugins.JavaPluginExtension;
19+
import org.gradle.api.tasks.TaskAction;
20+
21+
import static org.eclipse.edc.plugins.edcbuild.conventions.ConventionFunctions.requireExtension;
22+
23+
24+
public class PrintClasspathTask extends DefaultTask {
25+
26+
@TaskAction
27+
public void printClasspath() {
28+
var classpath = requireExtension(getProject(), JavaPluginExtension.class)
29+
.getSourceSets()
30+
.getByName("main")
31+
.getRuntimeClasspath()
32+
.getAsPath();
33+
34+
System.out.println(classpath);
35+
}
36+
37+
}

0 commit comments

Comments
 (0)