Define artifacts prior to dependent task definition

Hello:

I’d like be able to specify all of my gradle build script blocks in alphabetical order w/ tasks towards the bottom. For instance, I may specify this:

// build.gradle

artifacts {
  archives makeZip
  archives reportsZip
}

...

task makeZip {
	...
}
task reportsZip {
	...
}

However, on gradle 2.14, the following occurs:

cdaringe:\c\project/Build$ .gradlew

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\project/Build\build.gradle' line: 81

* What went wrong:
A problem occurred evaluating root project 'project'.
> Could not get unknown property 'makeZip' for object of type org.gradle.api.internal.artifacts.dsl.DefaultArtifactHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 0.811 secs

The /path\ delimiters above look a little wonky. Please forgive my combo of windows and git-bash. I doctored the paths for the share.

Anyway, it would be cool if i could do some task late binding as with the dependsOn clause. e.g. archives 'makeZip'. Is something like this feasible now?

Thanks!

You could try

artifacts {
  archives tasks.getByName('makeZip')
  archives tasks.getByName('reportsZip')
}

Hey @Lance_Java. Thanks for the suggestion!

$ ./gradlew tasks

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\my-project\build.gradle' line: 79

* What went wrong:
A problem occurred evaluating root project 'my-project'.
> Task with name 'makeZip' not found in root project 'my-project'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 0.812 secs

Looks like it didn’t take.

afterEvaluate {
   artifacts {
     archives makeZip
     archives reportsZip
   }
}