Pom files missing dependencies declared with implementation/api
emilaleborn opened this issue ยท 18 comments
In Gradle 4.0 compile dependencies has been deprecated and replaced with implementation/api. Dependencies declared with implementation/api does not appear as dependencies in the pom file when running install.
I am running into this issue as well. Hopefully dcendents can look into the issue before Android Studio 3 is released
looking at a java-library
project build with gradle 4.0 using the vanilla maven
plugin the pom looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>pom</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
<scope>compile</scope> <!-- api -->
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>1.13.0</version>
<scope>runtime</scope> <!-- implementation -->
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Hi everyone,
Sorry but the gradle 4.0 caught me in a bad time, I'm moving to a new house and there's a lot to do. Hopefully I'll be able to start looking into it this weekend or early next week.
Thanks for your patience.
I am sure we speak for everyone in saying thanks for taking the time to look at this when you can. Your plugin makes library development a lot easier and we look forward to your update to the project!
Sorry for not adding anything of value here, but I wanted to second @pang0018. Thanks for working on this and having kept it up-to-date for that long. I appreciate your work. :)
@dcendents do you perhaps have a status update? Multiple projects are still using 'compile' as we can't update to 'api' or 'implementation' unfortunately.
Well I was waiting for the android to complete their plugin (they are now in beta1: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html)
But it's taking a long time, I think I will do a release and some issue arise when they finally come out of beta then we'll deal with it later.
I'll try to do it tonight (GMT -05:00) but if not definitely this weekend.
I've updated the plugin to handle api and implementation using the latest android build plugin (3.0.0-beta3) which requires gradle 4.1
The build is passing so I'll be able to do the release tomorrow night.
@dcendents You're a star! Thank you.
Version 2.0 has been released, let me know if you have issues with it.
@dcendents we've done some testing today, however we do have some questions.
When using 'implementation' and 'implementation project(:project)' we've seen that for example gson (in the :project) won't leak into the application in which :project is used. As expected because implementation shouldn't leak. When using api the library does leak, like it should.
However... When using the 2.0 version of your library we've seen that for example gson in a library project with 'implementation' does leak into the app project. Using 'api' or 'implementation' doesn't make a difference at leaking the libraries, the only difference we've seen is that the libraries are exposed as runtime or compile in the pom.xml.
Do you know where the difference comes from?
@dcendents I am encountering the problem @Marc1510 described above. The output pom file has <scope>runtime</scope>
in its dependency node, but dependency is still leaking to main project in Android Studio.
@yakivmospan unfortunately not. Hope @dcendents will look into this one more time as it kinda defeats the purpose of defining scopes for the dependencies.
@Marc1510 thanks for reply. This looks like wrong gradle behavior, rather then library itself. Take a look at new gradle 4.6 release notes.
Since Gradle 1.0, runtime scoped dependencies have been included in the Java compile classpath, which has some drawbacks
I'm using pure new maven-publish
plugin, not the android-maven-gradle-plugin
, and even with this new experimental feature enabled(enableFeaturePreview('IMPROVED_POM_SUPPORT')
), it is still not working.
Now, if this new behavior is turned on, the Java and Java Library plugins both honor the separation of compile and runtime scopes.
Probably, android
and android-library
also must be updated on google side. And for sure this will be done not sooner then stable gradle 5.0 will be released.
I was using 1.5 version for android-maven-gradle-plugin in one of my libraries and started having transitive dependency issue. Was looking on the internet for a whole week. After updating the version to 2.1, the issue was resolved. Couldn't thank enough to you guys for posting this issue and giving the solution for that. Many thanks!
I still get this warning (using android-maven-gradle-plugin:2.1):
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.