2017-03-23 7 views
1

は、私はGradleのビルドに依存関係のセットを持って言う:gradleの依存関係バージョンをどのようにパラメータ化するのですか?

dependencies { 
    compile "org.springframework:spring-core:4.3.7.RELEASE" 
    compile "org.springframework:spring-context:4.3.7.RELEASE" 
    compile "org.springframework:spring-webmvc:4.3.7.RELEASE" 
    compile "org.springframework:spring-web :4.3.7.RELEASE" 
    ... 
} 

は新しいリリース5.0.0.RELEASEが出てくると言います。私はbuild.gradleの各依存関係を編集する必要はありません。

このファイルにすべての依存関係に使用できる変数を設定する方法はありますか?つまり、すべての依存関係を変更するのではなく、この変数の値を変更するだけです。

答えて

1

試してください:

apply plugin: 'java' 

repositories { 
    mavenCentral() 
} 

ext.ver = "4.3.7.RELEASE" 

dependencies { 
    compile "org.springframework:spring-core:$ver" 
    compile "org.springframework:spring-context:$ver" 
    compile "org.springframework:spring-webmvc:$ver" 
    compile "org.springframework:spring-web:$ver" 
} 
関連する問題