Zip task marked as relevant

Hi I'm trying to collect plugins from a subfolder, pin them and copy them to the export folder.

task buildPlugin {
  dependsOn ':empty-plugin:build'
}

task exportPlugin(type: Zip) {
  dependsOn buildPlugin

  // create new export folder as destination for nightly build
  def folder = '/export';
  def file = "${project.name}-sdk-${project.version}";

  // collect all plugins into cwc-sdk zip file
  baseName = file
  fileTree("cwc-plugin").each({
    if (it.name.endsWith(".zip")) {
        from it.absolutePath
    }
  })

  // move cwc-sdk zip file into export destination folder
  copy { into folder from file }
  delete file
}

      

First, I run a clean task. Gradle logs:

:api:compileJava
:api:processResources
:api:classes
:api:jar
:empty-plugin:compileJava
:empty-plugin:processResources
:empty-plugin:classes
:empty-plugin:jar
:empty-plugin:assemble
:empty-plugin:compileTestJava UP-TO-DATE
:empty-plugin:processTestResources UP-TO-DATE
:empty-plugin:testClasses UP-TO-DATE
:empty-plugin:test UP-TO-DATE
:empty-plugin:check UP-TO-DATE
:api:javadoc
:empty-plugin:zip
:empty-plugin:build
:buildPlugin
:exportPlugin UP-TO-DATE

BUILD SUCCESSFUL
Total time: 2.097 secs

      

On first run: exportPlugin is marked as UP-TO-DATE and I am not getting the zipped file from the assembly. When I run: exportPlugin everything is fine again. It's also fine when I link both tasks manually (rungradle clean, next run gradle buildPlugin, run gradle exportPlugin by duplicating tasks in IDEA)

I think the order of the tasks is still in order. I don't need to work with mustRunAfter

.

I also played with copySpec

, buildplugin.outputs.files

. But nothing helps.

Can anyone help me fix this issue for initial launch? Thank!

Update : The Zip task is an abstract copy task

AbstractCopyTask is the base class for all copy tasks. ( Docu )

I found this comment from Peter Niederwieser

The copy job only runs if it has something to copy. Telling what to copy is part of the task configuration and therefore needs to be done during the configuration phase, not during the runtime phase.

How do I change the line of code from it.absolutePath

inside the fileTree loop to be part during the configuration phase?

+3


source to share





All Articles