【问题标题】:Gradle - How to fetch ivy XML filesGradle - 如何获取 ivy XML 文件
【发布时间】:2015-11-05 09:57:09
【问题描述】:

我有一个 gradle 脚本,它基本上将 jar 从我们公司的存储库中提取到当前工作目录中。
我想做的是添加一个任务,该任务还将 ivy.xml 文件提取到另一个目录中。

build.gradle 看起来像这样:

repositories {  
    ivy {  
        url 'protocol://repo.foocompany.com/'
        credentials {
            username "foo"
            password "bar"
    }
    layout 'pattern', {
        artifact '[organisation]/[module]/[module]-[revision].[ext]'
        ivy '[organisation]/[module]/ivy-[revision].xml'
    }
}

dependencies {
    compile 'com.foocompany:bartifact:rev@ext'
}

task list << {
    configurations.compile.each {
        File file -> println file.name
    }
}

// that's the part I actually use
task fetch(type: Copy) {
    from configurations.compile
    into System.getProperty("user.dir")
}

task fetchXml {
    // and that's where I'm stuck no clue what I should put in there
}

运行脚本时,我的 fetch 任务按预期工作:

$> gradle fetch  
Download protocol://repo.foocompany.com/com.foo/bartifact/ivy-rev.xml  
Download protocol://repo.foocompany.com/com.foo/bartifact/bartifact-rev.ext  
:fetch  

$> ls  
bartifact-rev.ext  

而且我无法获取该 XML 文件。 我一直在尝试很多东西,但除了手动,我无法从 gradle 的缓存中获取它。

【问题讨论】:

    标签: java xml gradle build war


    【解决方案1】:

    只需为 Ivy 文件添加一个新的 Ivy 存储库:

    repositories {
        ivy {
            // Change the values here to match your environment.
            url 'http://archiecobbs.github.io/ivyroundup/repo/modules/'
            layout 'pattern', {
                artifact '[organisation]/[module]/[revision]/ivy.[ext]'
            }
        }
    }
    
    configurations {
        ivyFiles
    }
    
    dependencies {
        ivyFiles 'org.apache.geronimo.specs:activation:1.1@xml'
    }
    
    task downloadIvyFiles(type: Copy) {
        from configurations.ivyFiles
        into temporaryDir
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多