发布别的东西,而不是使用Gradle的jar到Nexus
我试图将Gradle与Ant结合使用来构建我们的OpenEdge项目。 OpenEdge是几个世纪以前的4GL语言。 ;-)发布别的东西,而不是使用Gradle的jar到Nexus
无论如何,我已经管理下载了一些jar依赖项,但现在我被困在如何将PL文件(Progress Library)发布到Nexus存储库中。事情就像Maven一样,Gradle似乎也是为Java项目制作的。
这是我的脚本(我也有rootProject.name = '蹬' 一个settings.gradle文件):
apply plugin:'java'
apply plugin: 'maven-publish'
group 'be.mips'
version = '1.4.0-SNAPSHOT'
repositories {
/*
Gradle uses the same logic as Maven to identify the location of your local
Maven cache. If a local repository location is defined in a settings.xml,
this location will be used. The settings.xml in USER_HOME/.m2 takes precedence
over the settings.xml in M2_HOME/conf. If no settings.xml is available, Gradle
uses the default location USER_HOME/.m2/repository.
*/
mavenLocal()
maven {
credentials {
username '****'
password '****'
}
url "http://srv-ci-nexus:8082/nexus/content/repositories/MadeApplReleases/"
url "http://srv-ci-nexus:8082/nexus/content/repositories/MadeApplSnapshots/"
}
mavenCentral()
}
def stompProgressLibraryFile = file('dist/lib/STOMP.PL')
artifacts {
archives stompProgressLibraryFile
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact stompProgressLibraryFile
}
}
repositories {
maven {
// default credentials for a nexus repository manager
credentials {
username '****'
password '****'
}
// url to the releases maven repository
url "http://srv-ci-nexus:8082/nexus/repositories/snapshots"
}
}
}
configurations {
antconf
}
dependencies {
antconf 'be.mips:mips-progress-ant-tasks:1.5.8-SNAPSHOT',
'be.mips:mips-pct:1.0-SNAPSHOT',
'ant-contrib:ant-contrib:1.0b3'
}
/* Loads the jars */
ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
configurations.antconf.each {
File f -> antClassLoader.addURL(f.toURI().toURL())
}
/* Extend clean task */
clean.doFirst {
delete '_ant_rcode', 'src', 'dist'
println 'deleted directories'
}
/* Create dist/lib directory as prolib does not create directory automatically */
task init(dependsOn: clean) {
doLast{
project.file('dist/lib').mkdirs()
println 'created dist/lib'
}
}
ant.importBuild 'build.xml'
运行gradle这个发布给了我一次输出:
C: \ Workspace \ git-repositories \ OpenEdge \ stomp.git> gradle -DDLC = C:\ OpenEdge \ 116 \ DLC publish:generatePomFileForMavenJavaPublication:compileJava UP-TO-DATE :processResources UP-TO-DATE:classes UP-TO- DATE:jar UP-TO-DATE :publishMavenJavaPublicationToMavenRep ository找不到元数据 be.mips:跺脚:在远程 (http://srv-ci-nexus:8082/nexus/repositories/snapshots)1.4.0-SNAPSHOT /行家-metadata.xml中上传 http://srv-ci-nexus:8082/nexus/repositories/snapshots/be/mips/stomp/1.4.0-SNAPSHOT/stomp-1.4.0-20161227.115652-1.pom 无法传送工件be.mips:跺脚:POM:1.4.0-20161227.115652 -1 从/到远程 (http://srv-ci-nexus:8082/nexus/repositories/snapshots):无法 写入到资源 '是/ MIPS /跺脚/ 1.4.0-SNAPSHOT /跺脚-1.4.0-20161227.115652-1.pom' 上传 http://srv-ci-nexus:8082/nexus/repositories/snapshots/be/mips/stomp/1.4.0-SNAPSHOT/stomp-1.4.0-20161227.115652-1.jar 莫非not transfer artifact be.mips:stomp:jar:1.4.0-20161227.115652-1 from/to remote (http://srv-ci-nexus:8082/nexus/repositories/snapshots):不能 写信给 'be/mips/stomp/1.4.0-SNAPSHOT/stomp-1.4.0-20161227.115652-1.jar' 上传 http://srv-ci-nexus:8082/nexus/repositories/snapshots/be/mips/stomp/1.4.0-SNAPSHOT/stomp-1.4.0-20161227.115652-1.pl 无法转移神器be.mips:stomp:pl:1.4.0-20161227.115652-1 从/到远程 (http://srv-ci-nexus:8082/nexus/repositories/snapshots):无法 写入到资源 '是/ MIPS /跺脚/ 1.4.0-SNAPSHOT/stomp-1.4.0-20161227.115652-1.pl' :publishMavenJavaPublicationToMavenRepository FAILED
失败:生成失败,出现异常。
出错了:执行失败的任务':publishMavenJavaPublicationToMavenRepository'。
无法发布发布“mavenJava”到存储库“行家” 无法部署工件:无法传送工件be.mips:跺脚:POM:从/到1.4.0-20161227.115652-1远程 (http://srv-ci-nexus:8082/nexus/repositories/snapshots ):无法 写入到资源 '是/ MIPS /跺脚/ 1.4.0-SNAPSHOT /跺脚,1.4.0-20161227.115652-1.pom'
尝试:用--stacktrace选项来运行获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。
构建失败
总时间:1.089秒
我注意到是有,我不需要这些Java任务的第一件事情。 :compileJava,:processResource,:classes,:jar ...
基本上我有一个build.xml的ant文件做我想要的一切。但蚂蚁的依赖管理非常差。所以我决定将Gradle与Ant结合使用。我希望Gradle为我做依赖管理。到目前为止,下载依赖关系似乎工作正常(将不得不尝试使用PL而不是jar)。但是发布别的东西而不是罐子,你是怎么做到的?
阅读了很多Gradle在线文档,但所有的例子似乎都基于java。
如果您不需要编译java代码,请使用base
插件而不是java
。你也应该删除from components.java
:
apply plugin: 'base'
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
artifact stompProgressLibraryFile
}
}
}
你的下一个错误“无法写入到资源”是最有可能不是一个问题的Gradle,检查仓库的写权限。发布到远程仓库之前,请尝试将其发布在本地仓库:
应用插件:
apply plugin: "maven"
执行任务install
:
$ ./gradlew install
THX!已从components.java中删除。接下来我会尝试基本插件。奇怪的是,这些东西并没有在网上Gradle用户指南中详细记录...... –