LoginSignup
2
2

More than 5 years have passed since last update.

Gradleでdependencyのjar等を読む方法

Last updated at Posted at 2014-02-13

dependency {
  compile 'jp.hogehoge.fugafuga'
  //省略
}

task("someDependencyOperation") << {
  def jarFile = configurations.compile.find { f -> f.name.matches("マッチしたいjar名等") }
  //jarFileは、見つかればjava.io.File、見つからない時はNullが返ります。
  //jarはzipファイル。zipの中身を調べたいときはzipTreeを使います。
  zipTree(jarFile).find { f -> f.name.equals("fugafuga") }
  //もちろん、jarFileそのものを操作してもOK
  jarFile.remaneTo("どこか")
  //maven dependency pluginの、mvn dependency:copy-dependenciesに相当するコマンドも実装出来ます
  configurations.compile.each { f ->
    //fを何処かにコピーとか
  }

}

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2