Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Pom file is missing transitive dependencies such as Google support libraries #53

Open
johnjohndoe opened this issue Oct 12, 2016 · 5 comments

Comments

@johnjohndoe
Copy link

johnjohndoe commented Oct 12, 2016

I maintain an Android library project where the dcendents.android-maven plugin is used to deploy to mavenLocal while developing and the gradle-nexus-plugin is used to publish to an internal Nexus repository.

The following Gradle configuration is used:

Top level build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:2.1.3"
        classpath "com.neenbedankt.gradle.plugins:android-apt:1.8"
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Library build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "com.github.dcendents:android-maven-gradle-plugin:1.4.1"
        classpath "com.bmuschko:gradle-nexus-plugin:2.3.1"
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.bmuschko.nexus'


group = project.groupId
version = project.versionName

android {
    compileSdkVersion Integer.parseInt(project.compileSdkVersion)
    buildToolsVersion project.buildToolsVersion

    defaultConfig {
        minSdkVersion Integer.parseInt(project.minSdkVersion)
        targetSdkVersion Integer.parseInt(project.targetSdkVersion)
        versionCode Integer.parseInt(project.versionCode)
        versionName project.versionName
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile "com.android.support:design:$project.supportVersion"
    compile "com.android.support:cardview-v7:$project.supportVersion"
}

modifyPom {
    project {
        name 'AndroidLibrary'
        description 'An Android library'
        url 'https://stash.company.lan/projects/repos/androidlibrary'
        inceptionYear '2016'

        scm {
            url 'https://stash.company.lan/projects/repos/androidlibrary'
            connection 'scm:https://stash.company.lan/scm/androidlibrary.git'
            developerConnection 'scm:ssh://git@stash.company.lan/androidlibrary.git'
        }
    }
}

extraArchive {
    sources = true
    tests = true
    javadoc = true
}

nexus {
    sign = true
    repositoryUrl = "http://internal/repository/company-internal-releases/"
    snapshotRepositoryUrl = "http://internal/repository/company-internal-snapshots/"
}

As you can see from the configuration the library itself depends on Google support libraries.

The problem

When integrating the library in an application project I noticed that the transitive dependencies of the library (speaking of the Google support libraries) can not be found by Gradle. This only happens when I reference mavenLocal(). When I reference the Nexus repository everything is fine.

When I compare the pom files from mavenLocal() and Nexus it can be seen that the one deployed to mavenLocal() is missing the transitive dependencies.

Pom file from mavenLocal

<?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>com.company.library.androidlibrary</groupId>
  <artifactId>androidlibrary</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>aar</packaging>
  <name>Search field</name>
  <description>An Android library</description>
  <url>https://stash.company.lan/projects/repos/androidlibrary</url>
  <inceptionYear>2016</inceptionYear>
  <scm>
    <connection>scm:https://stash.company.lan/scm/androidlibrary.git</connection>
    <developerConnection>scm:ssh://git@stash.company.lan:androidlibrary.git</developerConnection>
    <url>https://stash.company.lan/projects/repos/androidlibrary</url>
  </scm>
</project>

Pom file from Nexus

<?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>com.company.library.androidlibrary</groupId>
  <artifactId>androidlibrary</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>aar</packaging>
  <name>Search field</name>
  <description>An Android library</description>
  <url>https://stash.company.lan/projects/repos/androidlibrary</url>
  <inceptionYear>2016</inceptionYear>
  <scm>
    <connection>scm:https://stash.company.lan/scm/androidlibrary.git</connection>
    <developerConnection>scm:ssh://git@stash.company.lan:androidlibrary.git</developerConnection>
    <url>https://stash.company.lan/projects/repos/androidlibrary</url>
  </scm>
  <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>design</artifactId>
      <version>23.4.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>cardview-v7</artifactId>
      <version>23.4.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

Related issues

@johnjohndoe
Copy link
Author

@dcendents Any comment?

@dcendents
Copy link
Owner

Hi,

Sorry I lack personal time right now to work on this project and I'm not currently working on Android projects at work either at the moment so it's a bit hard to test all the different issues that are reported.

I need to build some test project(s) to cover all the different scenarios and I plan to work on that next.

Otherwise concerning your particular issue I will need to review the gradle-nexus-plugin to understand what it is doing differently.

I hope to come back to you soon.

Cheers

@johnjohndoe
Copy link
Author

Thank you for taking time to respond. I respect this and appreciate your work. If I have time myself I will try to digg into the plugin(s) myself.

@Onlinedispatcher
Copy link

Did you find any solution for that? Having the same issue...

@johnjohndoe
Copy link
Author

@Onlinedispatcher Sorry, but I did not investigate further.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants