noob234
noob234

Reputation: 239

How to exclude data source dependency before building the JAR file?

I have a library with different dependencies, and I want to exclude/ignore all data source dependencies when I introduce this library in my API.

I know that I can easily ignore dependencies in my API by using exclude:

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})

But how do I do that on the "Gradle" level, how do I do that in my library before building the JAR file and before using it in my API?

Upvotes: 0

Views: 447

Answers (2)

noob234
noob234

Reputation: 239

The best approach for me was to use:

compileOnly 'org.example'
testImplementation 'org.example'

Upvotes: 0

Simon Martinelli
Simon Martinelli

Reputation: 36223

You have to use the appropriate scope.

Read more about scopes: https://docs.gradle.org/current/userguide/declaring_dependencies.html

Upvotes: 1

Related Questions