我对Gradle非常陌生。我正在尝试编写两个任务:
这是到目前为止我得到的:
plugins {
id 'maven-publish'
}
def mafftGroupId = 'jp.cbrc.mafft'
def mafftArtifactId = 'mafft'
def mafftVersion = '7.388'
def artifactsDir = 'artifacts'
def mafftResourcesDir = 'resources/m2'
// TODO: De-duplicate these
def linux64TarballFile = file("$artifactsDir/mafft-$mafftVersion-linux.tgz")
def linux64TarballArtifact = artifacts.add('archives', linux64TarballFile) {
classifier = 'linux'
type = 'tgz'
}
def macZipFile = file("$artifactsDir/mafft-$mafftVersion-mac.zip")
def macZipArtifact = artifacts.add('archives', macZipFile) {
classifier = 'mac'
type = 'zip'
}
def win64ZipFile = file("$artifactsDir/mafft-$mafftVersion-win64-signed.zip")
def win64ZipArtifact = artifacts.add('archives', win64ZipFile) {
classifier = 'win64'
type = 'zip'
}
publishing {
publications {
mafft(MavenPublication) {
groupId mafftGroupId
artifactId mafftArtifactId
version mafftVersion
artifact linux64TarballArtifact
artifact macZipArtifact
artifact win64ZipArtifact
}
}
repositories {
maven {
name 'artifactory'
url 'https://biomatters.jfrog.io/biomatters/libs-release-local'
credentials {
username = artifactoryUser
password = artifactoryPassword
}
}
}
}
// TODO: This should maybe have a type of PublishToMavenRepository but I couldn't figure it out.
task publishMafftToArtifactory {
dependsOn 'publishMafftPublicationToArtifactoryRepository'
}
configurations {
mafftArchives
}
dependencies {
// TODO: Is there a way to just use the artifact files here?
mafftArchives(group: mafftGroupId, name: mafftArtifactId, version: mafftVersion, classifier: 'linux', ext: 'tgz')
mafftArchives(group: mafftGroupId, name: mafftArtifactId, version: mafftVersion, classifier: 'mac', ext: 'zip')
mafftArchives(group: mafftGroupId, name: mafftArtifactId, version: mafftVersion, classifier: 'win64', ext: 'zip')
}
task unpackMafft(type: Copy) {
// TODO: De-duplicate this too
configurations.mafftArchives.asFileTree.filter { File f ->
f.name.endsWith(".zip")
}.each {
from(zipTree(it))
}
configurations.mafftArchives.asFileTree.filter { File f ->
f.name.endsWith(".tgz")
}.each {
from(tarTree(it))
}
rename "mafft-linux64", "Linux64"
rename "mafft-mac", "OSX"
rename "mafft-win", "W64"
into "$mafftResourcesDir"
}
错误是:
FAILURE: Build failed with an exception.
* Where: Build file '/source/trunk/plugins/MafftPlugin/build.gradle' line: 71
* What went wrong: A problem occurred evaluating project ':plugins:MafftPlugin'.
> Could not resolve all files for configuration ':plugins:MafftPlugin:mafftArchives'.
> Could not find mafft-win64.zip (jp.cbrc.mafft:mafft:7.388).
我想知道是否可以根据运行的任务来确定依赖项的条件,但是据我所知,配置在任何任务图信息可用之前就已经完成。
这让我感到困惑。我不知道该怎么办。
欢呼