我有一个自定义任务来执行 Websphere EJBDeploy。我已经定义了输入和输出,并获得了成功的增量编译,但我无法让自动生成的清理任务正常工作。
根据文档,对于具有定义输出的名为“ejbDeploy”的自定义任务,应该自动生成一个 cleanEjbDeploy 任务。
Pattern: clean<TaskName>: Cleans the output files of a task.
所以这是我的自定义任务:
task ejbDeploy(dependsOn: 'jar'){
srcFile = file(jar.archivePath)
destDir = new File("build/ejbDeploy")
inputs.file srcFile
outputs.dir destDir
def cp = project.files(
project.sourceSets.main.output.classesDir,
project.sourceSets.main.resources,
project.configurations.runtime
).getAsPath()
doLast{
destDir.mkdirs()
exec{
executable = wasEjbDeploy
workingDir = destDir
args = [
jar.archivePath,
".",
jar.archiveName,
"-cp",
cp
]
}
}
}
任何人都知道为什么清洁规则不起作用?
[编辑]
这是完整的(匿名)文件内容(自最初的问题发布以来已更改):
version = '1.0-SNAPSHOT'
group = 'com.company'
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath group: 'name.benjaminAbbitt', name: 'WASEjbDeploy', version: '1.0-SNAPSHOT'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'base'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile 'javax.mail:mail:1.4.5'
compile 'log4j:log4j:1.2.16'
compile files(fileTree(dir: 'lib', includes: ['*.jar']) )
}
task ejbDeploy(type:name.benjaminAbbitt.WASEjbDeploy, dependsOn: 'jar'){
wasEjbDeployPath = wasEjbDeploy
}
这是“$gradle tasks”的相关块
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend
on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles the main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles the test classes.
Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.
Help tasks
----------
dependencies - Displays the dependencies of project ':project'.
help - Displays a help message
projects - Displays the sub-projects of project ':project'.
properties - Displays the properties of project ':project'.
tasks - Displays the tasks runnable from project ':project' (some of the
displayed tasks may belong to subprojects).
IDE tasks
---------
cleanEclipse - Cleans all Eclipse files.
eclipse - Generates all Eclipse files.
Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.
Other tasks
-----------
ejbDeploy
Rules
-----
Pattern: build<ConfigurationName>: Assembles the artifacts of a configuration.
Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belongin
g to a configuration.
Pattern: clean<TaskName>: Cleans the output files of a task.
To see all tasks and more detail, run with --all.
BUILD SUCCESSFUL
Total time: 3.321 secs