更新build.grade以构建warfile并将其推送到artifactory

时间:2015-12-07 18:55:41

标签: gradle build.gradle artifactory

我的string[] lis = {"a","b","a.a","a.ab","c","cc.a","a.b.dd","samad.hah.hoh"}; treeView1.Nodes.Clear(); TreeBuilder Troot = new TreeBuilder(); TreeBuilder son; Troot.depth = 0; Troot.index = 0; Troot.text = "root"; Troot.childs = new Dictionary<string, TreeBuilder>(); foreach (string str in lis) { string[] seperated = str.Split('.'); son = Troot; int index= 0; for (int depth = 0; depth < seperated.Length; depth++) { if (son.childs.ContainsKey(seperated[depth])) { son = son.childs[seperated[depth]]; } else { son.childs.Add(seperated[depth],new TreeBuilder()); son = son.childs[seperated[depth]]; son.index= ++index; son.depth = depth+1; son.text = seperated[depth]; son.childs = new Dictionary<string, TreeBuilder>(); } } } treeView1.Nodes.Add("root"); Troot.addToTreeVeiw(treeView1.Nodes[0], Troot); 进行了以下更改,以构建warfile并解决artifactory的依赖关系:

build.gradle

当我尝试构建此代码时,出现错误:

  

无法解析外部依赖关系abc:1.0.0,因为没有定义存储库。

为了解决这个错误,我添加了这个:

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

    war {
        classpath configurations.warLib
        classpath = classpath.files
    }

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

注意

这意味着神器中的resolve选项无法解析,我认为这是因为我构建war文件的方式。我该如何解决它,以便我可以构建war文件并使用artifactory中的resolve选项?

1 个答案:

答案 0 :(得分:1)

您忘记应用artifactory插件:

apply plugin: "com.jfrog.artifactory"