13
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

実行可能Jarだけど、依存するJarを内包しない形式にしてみました

Last updated at Posted at 2015-05-12

依存する外部Jarを内包せずにJarを作成することができました。依存する外部Jarはlibs/下に収めます。

build.gradle

マニフェストにClass-Pathを追加する
jar {
  manifest.attributes(
    // 依存する外部Jarはlibs/下にあるものとしてClass-Pathを設定します
   'Class-Path': configurations.runtime.files.collect { 'libs/' + it.name }.join(' ')
  )
}
依存する外部Jarをlibs/下にコピーします
task copyDependencies << {
 new File('libs').mkdirs()
 copy {
  from configurations.runtime
  into 'libs'
 }
}

参考

13
15
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
13
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?