Kendall Shaw
04/02/2024, 5:32 AMtasks.register('dist', Copy) {
description = 'Copy files to dist.'
group = BasePlugin.BUILD_GROUP
destinationDir = 'dist' as File
def data_archive = project.properties('data.archive')
it.from('build/libs/some-${version}.jar') {
into 'some.jar'
}
it.from('src/main/groovy/some.groovy')
it.from(data_archive)
}
Actually, this creates a directory named some.jar. How do I copy into the destinationDir with a different name?Thomas Broyer
04/02/2024, 7:09 AMrename
on the copy spec (https://docs.gradle.org/current/javadoc/org/gradle/api/file/CopySpec.html#rename-org.gradle.api.Transformer-; there's an example in https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Copy.html)
Btw, you'll want to reference the task that produces the JAR, rather than directly referencing the JAR filename, something like (untested, particularly as I haven't written Groovy in years):
from(tasks.jar.archiveFile) {
rename { 'some.jar' }
}
Vampire
04/02/2024, 7:29 AMtasks.jar
, unless there are multiple outputs on that task. :-)Vampire
04/02/2024, 7:29 AMSync
instead of Copy
. It makes sure there are no stale files.Kendall Shaw
04/02/2024, 8:12 AM