# Gradle upgrade - dependency problems

**URL:** <https://discuss.gradle.org/t/gradle-upgrade-dependency-problems/47803>\
**Category:** Help/Discuss\
**Created:** [February 26, 2024, 9:38am UTC](https://discuss.gradle.org/t/gradle-upgrade-dependency-problems/47803 "2024-02-26T09:38:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zchovan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zchovan/32/10840_2.png) [@zchovan](https://discuss.gradle.org/u/zchovan)\
**Post date:** [February 26, 2024, 9:38am UTC](https://discuss.gradle.org/t/gradle-upgrade-dependency-problems/47803/1 "2024-02-26T09:38:54Z")

</div>

Hi!

I’m upgrading (6.x-\>7.6) a multi-project gradle repository. I have a subproject that has had a dependency declaration like the following:

```gradle
dependencies {
  compile libs.hdrhistogram
  compile libs.yetusAnnotations

  provided libs.scalaLibrary
  provided libs.sparkCore
  provided libs.sparkSql
  provided libs.slf4jApi

  testCompile libs.junit
  testCompile libs.scalatest
  testCompile libs.log4jApi
  testCompile libs.log4jCore
  testCompile libs.log4jSlf4jImpl
}

```

Based on the upgrade guide ([Upgrading your build from Gradle 6.x to 7.0](https://docs.gradle.org/current/userguide/upgrading_version_6.html)) and the maven migration guide ([Migrating Builds From Apache Maven](https://docs.gradle.org/current/userguide/migrating_from_maven.html#migmvn:migrating_deps)) I changed the dependencies to as follows:

```gradle
dependencies {
  implementation libs.hdrhistogram
  implementation libs.yetusAnnotations

  implementation libs.scalaLibrary
  implementation libs.sparkCore
  implementation libs.sparkSql
  implementation libs.slf4jApi

  testImplementation libs.junit
  testImplementation libs.scalatest
  testImplementation libs.log4jApi
  testImplementation libs.log4jCore
  testImplementation libs.log4jSlf4jImpl
}

```

Unfortunately the project doesn’t compile when setting the provided dependencies to compileOnly.  
The problem comes when I inspect the contents of the created jar. Previously the generated jar did not include the scala/spark/slf4j classes, however after the change the jar size has exploded from 17Mb to 130Mb. Try as I might I can’t really find a simple way to define depenencies to be used during compile, but exclude during the jar task. Am I missing something, or should I use a specific plugin for this?

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [February 27, 2024, 8:55am UTC](https://discuss.gradle.org/t/gradle-upgrade-dependency-problems/47803/2 "2024-02-27T08:55:39Z")

</div>

Some points here.

- why does it not compile with `compileOnly`? If something is `compileOnly` it is available at compile time, so it sounds unlikely that it is not available at compile time.
- how to define something that “is available during compile but excluded during the jar task” cannot be answered without seeing your build, because Gradle does not build bad-practice fat jars at all, unless you configure it to and if you do, it depends on how you do it, but generally, you would pack the `runtimeClasspath` while using `compileOnly`. If you really need to build such a bad practice fat jar, I’d recommend you at least use John Engelman’s `shadow` plugin, which sails around some of the cliffs at least.
