Gradle provided dependencies with Intellij

后端 未结 3 1343
感动是毒
感动是毒 2021-01-21 10:48

I\'m trying to build a Bukkit plugin. The plugin also uses exp4j. The final result needs to have the exp4j code included in the released jar but not have the Bu

3条回答
  •  余生分开走
    2021-01-21 11:16

    See Gradle issue here.

    There isn't a provided configuration in gradle, though there really should be one. The most reasonable workaround currently seems to be, to create your own configuration:

    configurations {
        provided
    }
    

    and then:

    sourceSets {
        main {
          compileClasspath += configurations.provided
        }
    }
    

    The problem with extendsFrom is that the provided dependency will end up being bundled in your distribution anyway unless if you add another explicit exclude, defeating the whole point of provided.

    Edit: To tell idea to use the provided dependencies, you could apply the 'idea' plugin and then:

    idea {
      module {
        scopes.PROVIDED.plus += [ configurations.provided ]
      }
    }
    

    see more here.

提交回复
热议问题