【发布时间】:2014-06-22 05:18:56
【问题描述】:
我正在为 gradle 构建我的第一个自定义插件。这个插件做了很多事情,包括根据项目拥有的其他插件配置它所应用的项目。我希望这个插件做的一件事是处理所有的 Maven 发布工作,这样它就不需要出现在每个 build.gradle 中。每个构建都执行完全相同的操作,它们只有源 Jar 和基础项目 Jar,并且都已(或将)发布到我们的工件存储库。
这行得通,我可以创建 Jar 文件。但是,Jar 文件只包含 META-INF 文件夹和清单文件,没有项目的任何类。有没有人遇到过这个问题并知道原因?
// Configure Jar Manifest
jar {
manifest = project.manifest {
from sharedManifest
}
}
// Configure sources Jar manifest
(project.getTasks()).create("sourcesJar", Jar) {
classifier "sources"
from project.sourceSets.main.allSource
manifest = project.manifest {
from sharedManifest
}
}
artifacts {
archives project.tasks.sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from project.components.java
artifact project.tasks.sourcesJar
pom.withXml {
def root = asNode()
root.appendNode("name", project.name)
root.appendNode("description", project.name + "component of company.")
root.appendNode("inceptionYear", "2010")
}
}
}
repositories {
maven {
//We only publish to the Releases repository if the project is given the property "release"
if(project.hasProperty("release")) {
url "http://clipped/"
} else {
url "http://clipped/"
}
credentials {
if(project.hasProperty("nexusUsername") && project.hasProperty("nexusPassword"))
{
username = nexusUsername
password = nexusPassword
}
}
}
}
}
【问题讨论】:
-
问题可能出在上面显示的代码以外的地方。可能源代码在错误的目录中,或者其他构建脚本有问题。
标签: plugins jar gradle publish