使用gradle将war文件发布到artifactory

Jas*_*son 3 java artifactory gradle build.gradle

所以,下面的war文件发布了jar文件和war文件。它发布战争文件,因为我在发布下将其指定为“工件(文件('build/libs/new_file-1.0.war'))”。

问题 1:有没有办法在不指定全名的情况下发布战争文件?

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

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
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

问题 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'
}
Run Code Online (Sandbox Code Playgroud)

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

有人可以帮忙吗。

RaG*_*aGe 7

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

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