Skip to content

Commit

Permalink
feat: make edc-build register printClasspath plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Mar 29, 2024
1 parent c63ddb5 commit 44f27f5
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.mavenPublication;
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.mavenPublishing;
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.nexusPublishing;
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.printClasspath;
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.repositories;
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.rootBuildScript;
import static org.eclipse.edc.plugins.edcbuild.conventions.Conventions.signing;
Expand Down Expand Up @@ -74,7 +75,8 @@ public void apply(Project target) {
allDependencies(),
tests(),
jar(),
swagger()
swagger(),
printClasspath()
).forEach(c -> c.apply(project));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public static EdcConvention checkstyle() {
return new CheckstyleConvention();
}


public static EdcConvention mavenPublishing() {
return new MavenPublishingConvention();
}
Expand Down Expand Up @@ -87,4 +86,8 @@ public static EdcConvention openApiMerger() {
public static EdcConvention mavenPublication() {
return new MavenPublicationConvention();
}

public static EdcConvention printClasspath() {
return new PrintClasspathConvention();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/

package org.eclipse.edc.plugins.edcbuild.conventions;

import org.eclipse.edc.plugins.edcbuild.tasks.PrintClasspathTask;
import org.gradle.api.Project;

public class PrintClasspathConvention implements EdcConvention {
@Override
public void apply(Project target) {
target.getTasks().register("printClasspath", PrintClasspathTask.class)
.configure(t -> t.dependsOn("compileJava"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/

package org.eclipse.edc.plugins.edcbuild.tasks;

import org.gradle.api.DefaultTask;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.TaskAction;

import static org.eclipse.edc.plugins.edcbuild.conventions.ConventionFunctions.requireExtension;


public class PrintClasspathTask extends DefaultTask {

@TaskAction
public void printClasspath() {
var classpath = requireExtension(getProject(), JavaPluginExtension.class)
.getSourceSets()
.getByName("main")
.getRuntimeClasspath()
.getAsPath();

System.out.println(classpath);
}

}

0 comments on commit 44f27f5

Please sign in to comment.