LoginSignup
14
14

More than 5 years have passed since last update.

Gradle で maven の provided scope 相当

Last updated at Posted at 2013-04-08

Gradle 便利だけど、javax.servlet-api みたいに、実行時に maven 依存以外からロードされるような依存パッケージを指定する configuration が存在しない。

maven なら、<scope>provided</scope> でできるのに・・・

Gradle だと、それ相当を実装しないといけない。

こんな感じ:

// maven でいうところの provided scope のエミュレート
// 参考: http://www.gradle.org/docs/current/dsl/org.gradle.plugins.ide.eclipse.model.EclipseClasspath.html
configurations{ provided }
sourceSets {
    main { compileClasspath += configurations.provided }
    test {
        compileClasspath += configurations.provided
        runtimeClasspath += configurations.provided
    }
}
eclipse.classpath {
    plusConfigurations += configurations.provided
    noExportConfigurations += configurations.provided
}

以上です。

  糸冬
-----------------------
制作・著作 NHK

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