Home > Software engineering >  How to exclude data source dependency before building the JAR file?
How to exclude data source dependency before building the JAR file?

Time:07-22

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?

CodePudding user response:

You have to use the appropriate scope.

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

CodePudding user response:

The best approach for me was to use:

compileOnly 'org.example'
testImplementation 'org.example'
  • Related