This message was deleted.
# plugin-development
s
This message was deleted.
1
c
into(…)
is the equivalent of
mainSpec.addChild().into(…)
Copy code
val foo by tasks.registering(Sync::class) {
    into("something")
}
scratch that. Digging through Gradle internals - think this is what you want. DefaultCopySpec#from
Copy code
@Override
    public CopySpec from(Object sourcePath, Action<? super CopySpec> configureAction) {
        Preconditions.checkNotNull(configureAction, "Gradle does not allow passing null for the configuration action for CopySpec.from().");
        CopySpecInternal child = addChild();
        child.from(sourcePath);
        CopySpecWrapper wrapper = instantiator.newInstance(CopySpecWrapper.class, child);
        configureAction.execute(wrapper);
        return wrapper;
    }
Copy code
val pluginName = "blah"
val foo by tasks.registering(Sync::class) {
    from("$pluginName/lib") {
        
    }
}
It may be cleaner to mirror the existing behaviour, following the internals of the code is challenging. It does look like
into
mirrors the behaviour of adding a child copyspec and configuring it:
Copy code
@Override
    public CopySpec into(Object destPath, Action<? super CopySpec> copySpec) {
        Preconditions.checkNotNull(copySpec, "Gradle does not allow passing null for the configuration action for CopySpec.into().");
        CopySpecInternal child = addChild();
        child.into(destPath);
        CopySpecWrapper wrapper = instantiator.newInstance(CopySpecWrapper.class, child);
        copySpec.execute(wrapper);
        return wrapper;
    }

    @Override
    public CopySpec into(Object destPath, Action<? super CopySpec> copySpec) {
        getMainSpec().into(destPath, copySpec);
        return this;
    }
That problematic line of code appears to be equivalent to:
Copy code
val plugin = into(project.provider { "${pluginName.get()}/lib" })
j
@Chris Lee Thanks a lot for that idea – overriding
into
method and passing destination dir to the
mainSpec.addChild()
did the job!
👍 1