How to export dependencies?

There is a project. It has some dependencies using implementation and apiElements. If I only use implementatioin, other projects included this project could not use these dependencies. But, apiElements is getting removed in Gradle 8.0 because it tells me when I build with --warning-mode all.

The apiElements configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 8.0. Please use the implementation or compileOnly configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/7.0.1/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
        at build_esc6qj7ym1rlw80lcuzksq266$_run_closure1.doCall(xxxxxx\build.gradle:2)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

And I could not use api because “api configuration not found”. What configuration should I use?

apiElements was never meant to be used for declaring dependencies.
api is the one you want to use.
You are probably applying the java plugin but should instead apply the java-library plugin which adds the api configuration.

1 Like