Hello,
I am writing a Gradle plugin in Java to help with the distribution of our pipeline tasks.
Currently, I’ve got everything migrated and working as expected except for the Copy task. I am not sure what would be the proper way to configure multiple from
in it, as with the configuration below it is not picking up both files.
public class StageApp extends Copy {
private final CommonProperties commonProperties;
public StageApp() {
super();
this.commonProperties = getProject().getExtensions().getByType(CommonProperties.class);
configureTask();
}
private void configureTask() {
from(getProject().getBuildDir(), (copySpec) -> {
include("*.jar");
rename((it) -> getProject().getName() + ".jar");
});
from(
getProject().fileTree(getProject().getProjectDir() + "/config/" + commonProperties.getEnv())
.getFiles(), (copySpec -> include("configuration.yml")));
into(getProject().getRootDir() + "/docker/" + getProject().getName());
}
}
At the same time, this is working while having it as a task:
task stageApp(type: Copy, dependsOn: fetchArtifact) {
from(buildDir) {
include "*.jar"
rename { "${project.name}.jar" }
}
from(fileTree("${projectDir}/config/${env}").files) {
include "configuration.yml"
}
into("${rootDir}/docker/${project.name}")
}
Any idea of what am I missing here?
Thanks!