Bet*_*eto 6 deployment groovy gradle maven build.gradle
我需要将外部zip文件部署到我的私有maven存储库.这个文件将满足我的应用程序版本,内部存档将使用jar,dll,configs,exes来满足我的应用程序的文件结构......
如何使用gradle执行maven部署:deploy-file?
mvn deploy:deploy-file
-DgroupId=acme
-DartifactId=acme
-Dversion=1.0
-Dpackaging=jar
-Dfile=C:\tmp\acme-1.0.jar
-DrepositoryId=Nexus
-Durl=http://myserver:8888/nexus/content/repositories/thirdparty/
Run Code Online (Sandbox Code Playgroud)
我正在尝试将外部zip文件发布到我的maven存储库:
apply plugin: "base"
apply plugin: "maven"
apply plugin: "maven-publish"
publishing {
def host = "myhost"
def url = "http://$host/content/repositories/releases"
def group = "package"
def artifact = "name"
def version = "0.0.1"
def file = "c:/my.zip"
publications {
mavenJava(MavenPublication) {
create('zip', MavenPublication) {
groupId "$group"
artifactId "$artifact"
version "$version"
artifact file("$file")
}
}
}
repositories {
maven {
credentials {
username 'user'
password 'pwd'
}
url "$url"
}
}
}
publish.dependsOn build
Run Code Online (Sandbox Code Playgroud)
但是当它执行时,我得到了这个例外:
FAILURE: Build failed with an exception.
* Where:
Build file 'c:\xxxx\build.gradle' line: 18
* What went wrong:
A problem occurred configuring root project 'XXXXX'.
> Exception thrown while executing model rule: PublishingPlugin.Rules#publishing(ExtensionContainer)
> No signature of method: java.lang.String.call() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [0.0.1]
Possible solutions: wait(), any(), wait(long), any(groovy.lang.Closure), take(int), each(groovy.lang.Closure)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Run Code Online (Sandbox Code Playgroud)
有趣的案例,乍一看并不那么明显。问题在于此块中的方法 ( version, artifact):
mavenJava(MavenPublication) {
create('zip', MavenPublication) {
groupId "$group"
artifactId "$artifact"
version "$version"
artifact file("$file")
}
}
Run Code Online (Sandbox Code Playgroud)
命名与此块中上面几行定义的变量完全相同:
def host = "myhost"
def url = "http://$host/content/repositories/releases"
def group = "package"
def artifact = "name"
def version = "0.0.1"
def file = "c:/my.zip"
Run Code Online (Sandbox Code Playgroud)
这里发生的事情是在发布块版本中评估为0.0.1,然后将具有相同值的参数传递给它,结果是:
"0.0.1"("0.0.1")
Run Code Online (Sandbox Code Playgroud)
它解释了错误消息:
没有方法签名:java.lang.String.call() 适用于参数类型:(org.codehaus.groovy.runtime.GStringImpl)
事实上,第二个参数不会是GString裸露的String,其次在 groovy 中的类上没有call定义任何方法来String接受 a 的实例String。
我为所有有问题的名称添加了任何后缀:
apply plugin: "base"
apply plugin: "maven"
apply plugin: "maven-publish"
publishing {
def host = "myhost"
def urlWhataver = "http://$host/content/repositories/releases"
def group = "package"
def artifactWhatever = "name"
def versionWhatever = "0.0.1"
def path = "c:/my.zip"
publications {
mavenJava(MavenPublication) {
create('zip', MavenPublication) {
groupId "$group"
artifactId "$artifactWhatever"
version "$versionWhatever"
artifact new File("$path")
}
}
}
repositories {
maven {
credentials {
username 'user'
password 'pwd'
}
url "$urlWhataver"
}
}
}
publish.dependsOn build
Run Code Online (Sandbox Code Playgroud)
$path转换也有问题。
| 归档时间: |
|
| 查看次数: |
994 次 |
| 最近记录: |