Transitive Dependencies, buildSrc and Integration Testing

I’m trying to get transitive dependencies to work in my plugin which currently resides in the buildSrc directory. To verify that the dependencies are getting pulled in I have created a set of integration test. You can see my set up here:

https://gist.github.com/Scuilion/6528120

and the integration project build file look like this:

buildscript {
    repositories {
        mavenCentral()
        flatDir {
            dirs '../build/libs/buildings/myMavenName/1.0'
        }
    }
    dependencies {
        classpath group: 'buildings', name: 'myMavenName', version: '1.0'
    }
}
  apply plugin: 'run-simple'
  repositories {
    mavenCentral()
    flatDir {
        dirs '../build/libs/buildings/myMavenName/1.0'
    }
  }
  runSimple {
    main = 'com.kronos.sandbox.RunIt'
}

When I use my buildscript it does not automatically download the Apache commons lib jar. When I build and publish the plugin I’m creating a POM and I can see the dependency but I still can’t seem to get it to work.

You can see the whole example project on github. https://github.com/Scuilion/gradle-integ

Thanks.

For a standalone plugin that you want to publish to a repository I’d rather create a separate project. Make sure that you provide an appropriate group and version. From that plugin project you can upload the plugin JAR/POM to a local Maven repository like this:

group = 'buildings'
version = '1.0'
  uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file://$projectDir/../repo")
        }
    }
}

Then in the consuming (separate) project you can pull it in like this:

buildscript {
    repositories {
        maven { url "file://$projectDir/../repo" }
        mavenCentral()
    }
      dependencies {
        classpath 'buildings: myMavenName:1.0'
    }
}
  apply plugin: 'run-simple'

In your code above you are not pointing to a Maven repository but to a flat directory. Hope this helps.

So a flatDir repository doesn’t read the pom file. That makes sense. I assumed that there was a simple solution to my problem but had stared at it for too long. Thanks for taking the time to respond.