我有一个静态xml文件,我想从Gradle使用maven-publish插件发布到Maven存储库(现在是我的本地Maven回购)。如何从Gradle发布XML文件到Maven回购
的build.gradle看起来是这样的:
apply plugin: 'maven-publish'
group 'com.example.gradletest'
version '1.0-SNAPSHOT'
publishing {
publications {
beta(MavenPublication) {
artifactId 'feature-file'
artifact 'src/main/resources/features.xml'
}
}
}
这工作,但我想补充的分类太,我应该在哪里定义呢? https://docs.gradle.org/current/userguide/publishing_maven.html说,在部分68.2.2,它应该是可以做到的:
publishing {
publications {
beta(MavenPublication) {
artifactId 'feature-file'
artifact ('src/main/resources/features.xml') {
classifier 'features'
}
}
}
}
但后来我得到这个错误:
的问题发生在配置根项目“testapplication”。
Exception thrown while executing model rule: org.gradle.api.publish.plugins.PublishingPlugin$Rules#publishing(org.gradle.api.plugins.ExtensionContainer) No signature of method: java.io.File.call() is applicable for argument types: (build_101arjzoe908rdkh5aikrn6bt$_run_closure5_closure16_closure19_closure20) values: [build_101arj[email protected]2aa7399c] Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), any(groovy.lang.Closure), list()
使用下面的解决方案将正确添加的分类,同时也将改变在pom.xml包装从<packaging>xml</packaging>
到<packaging>pom</packaging>
。我不想那样。
publishing {
publications {
beta(MavenPublication) {
artifactId 'feature-file'
artifact source: 'src/main/resources/features.xml', classifier: 'features'
}
}
}
是的,这增加了分类,但它也改变了从XML到POM的包装。我不想那样。 – npeder