java - 使用gradle将war文件发布到artifactory

标签 java gradle build.gradle artifactory

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

问题一:有没有办法不指定全名发布war文件?

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

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
            }
        }
    }

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

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'
}

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

有人可以帮忙吗?

最佳答案

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

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

关于java - 使用gradle将war文件发布到artifactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34344204/

相关文章:

java - 如何快速从大缓冲图像中获取小图像

android - 构建类型始终为 "Release"

java - mac上设置java环境变量失败

java - 为什么这两种获取 boolean 值的方法会得到不同的结果?

java - 向复合组件添加操作方法

gradle - Gradle,无法通过代理访问在线存储库

android - 默认情况下在gradle中为从proto文件生成的类注册一个包,而不是在proto文件中

android - 如何在 Github 上创建库并通过 Android Studio 中的 gradle 依赖项使用它

gradle - 将项目(模块)声明为另一个项目(另一个模块)中的依赖项但失败

android - 从另一个项目编译模块