Gradle で archives configuration の非推奨化に対処する

blog1.mammb.com


The archives configuration has been deprecated for consumption

ear プラグインなどで、別モジュールの war を参照する際は、以下のように archives configuration で指定できる。

plugins {
    ear  
}  
  
dependencies {
    deploy(project(":war", "archives"))
}

archives configuration は以下のように Gradle 9 で非推奨となり、Gradle 10 で利用できなくなる予定となっている。

The archives configuration has been deprecated for consumption.
- This will fail with an error in Gradle 10.


モジュール artifact の指定

war モジュール側で、以下のように artifact を明示することで、

plugins {
    war  
}  
  
configurations.runtimeElements.get().outgoing.artifact(tasks.war.get())

ear モジュール側で以下のようにすることができる。

plugins {
    ear  
}  
  
dependencies {
    deploy(project(":war"))
}

なお、jar を生成するモジュールの場合は、デフォルトで artifact に jar が設定されているため、明示的な artifact の指定は不要である。