使用gradle将war文件发布到artifactory [英] Publishing war file to artifactory using gradle

查看:162
本文介绍了使用gradle将war文件发布到artifactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,下面的war文件发布jar文件和war文件。它发布了war文件,因为我在出版物中指定它为artifact(file('build / libs / new_file-1.0.war'))。

问题1:是否有办法在不指定全名的情况下发布war文件?

问题2:为什么要发布jar文件?我甚至没有建造它?

  buildscript {
repositories {
maven {
url'http:// localhost / artifactory / plugins-release'
credentials {
username =$ {artifactory_user}
password =$ {artifactory_password}
}
}
依赖关系{
classpath(group:'org.jfrog.buildinfo',name:'build-info-extractor-gradle',version:'3.1.1')
}
configurations {
warLib {
transitive = false
}
}
}

应用插件:com.jfrog.artifactory
apply plugin:'eclipse'
apply plugin:'java'
apply plugin:'maven'
apply plugin:'maven-publish'
apply plugin:'war'

war {
classpath configurations.warLib
}

发布{
publi
mavenJava(MavenPublication){
from components.java
artifact(file('build / libs / new_file-1.0.war'))
}
}
}

artifactory {
contextUrl =$ {artifactory_contextUrl}//如果发布者/解析器未覆盖基本Artifactory URL
发布{
存储库{
repoKey ='aaa'
用户名=$ {artifactory_user}
密码=$ {artifactory_password}
maven = true
}

defaults {
publications('mavenJava')
publishPom = false
}
}
解决方案{
repository {
repoKey ='aba'
username =$ {artifactory_user}
password =$ {artifactory_password}
maven = true
}
}
}

问题3:是否有办法将特定的库作为依赖项的一部分提取到特定的位置?

 依赖关系{
编译组:'a',名称:'application_jar',版本:'1.0'
编译组:'b',名称:'newlock',版本:'1.0.0'
testCompile组:'unit',名称:'unit',版本:'1.0'
}

从上面的依赖关系中,我想将库 a 拉入不同的目录,可以说构建/ deps和所有其他的到$ HOME中的.gradle目录。

有人可以请帮忙吗?

解决方案

#2。 刊物{} 部分定义发布的内容。来自components.java 的行添加了jar文件。如果您不想发布该jar,请删除该行。



#1要发布war插件生成的war文件,请使用 components.web


So, the below war file publishes the jar file and the war file. It publishes the war file because I have it specified under publications as "artifact(file('build/libs/new_file-1.0.war'))".

Question 1: Is there a way to publish war files without specifying full names ?

Question 2: Why is the jar file being published ? I am not even building it ?

buildscript {
    repositories {
        maven {
            url 'http://localhost/artifactory/plugins-release'
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
        }
        dependencies {
            classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '3.1.1')
        }
        configurations {
            warLib {
                transitive=false
            }
        }
    }

    apply plugin: "com.jfrog.artifactory"
    apply plugin: 'eclipse'
    apply plugin: 'java'
    apply plugin: 'maven'
    apply plugin: 'maven-publish'
    apply plugin: 'war'

    war {
        classpath configurations.warLib
    }

    publishing {
        publications {
            mavenJava(MavenPublication) {
                from components.java
                artifact(file('build/libs/new_file-1.0.war'))
                }
        }
    }

    artifactory {
        contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
        publish {
            repository {
                repoKey = ‘aaa'
                username = "${artifactory_user}"
                password = "${artifactory_password}"
                maven = true
            }

            defaults {
                publications('mavenJava')
                publishPom = false
            }
        }
        resolve {
            repository {
                repoKey = ‘aba'
                username = "${artifactory_user}"
                password = "${artifactory_password}"
                maven = true
            }
        }
    }

Question 3: Is there a way to pull specific libraries as part of dependencies into specific location ?

dependencies {
    compile group: 'a', name: 'application_jar', version: '1.0'
    compile group: 'b', name: 'newlock', version:'1.0.0'
    testCompile group: 'unit', name: 'unit', version:'1.0'
}

From the above dependencies, I want to pull library a into different directory, lets say build/deps and all the other ones into the .gradle directory in $HOME.

Can somebody please help.

解决方案

#2. The publications{} section defines what is published. The line from components.java adds the jar file. If you do not want to publish the jar, remove that line.

#1 To publish the war file generated by the war plugin, use from components.web

这篇关于使用gradle将war文件发布到artifactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆