How to specify a ProjectDependency on a custom publishing artifact?


(steve) #1

Following the examples from 63.2.2 (Publishing custom artifacts) at http://www.gradle.org/docs/current/userguide/publishing_maven.html I have created the following snippet:

task testingJar(type: Jar, dependsOn: testClasses) {
    classifier = 'testing'
    from sourceSets.test.output
    include '**/org/hibernate/testing/**'
}
  publishing {
    publications {
        mavenJava {
            // add testing jar as a publication
            artifact testingJar {
                classifier 'testing'
            }
        }
    }
}

This is part of a multi-project build. In other projects, how can I refer to that ‘testing’ artifact?

Using the older configuration approach, we used to have project-dependencies that specified the configuration ala:

testCompile( project(path: ':hibernate-entitymanager', configuration: 'tests') )

But trying that here fails:

testCompile( project(path: ':hibernate-core', configuration: 'testing') )

The only way I found this to work was to explicitly add a configurations block:

configurations {
    testing
}
artifacts {
    testing testingJar
}

Should this be necessary? Is there another way I should specify this dependency?


(steve) #2

Also, the include filter for the testingJar task has no effect (all files are added). Am I doing something wrong there?


(steve) #3

Also, the include filter for the testingJar task has no effect (all files are added). Am I doing something wrong there?


(steve) #4

There is probably a bigger issue here too. I cannot see a way to define distinct POMs for the ‘jar’ and ‘testing’ artifacts (the testing artifact requires additional transitive dependencies).

Using the Publication DSL, is there an intended way to publish multiple artifacts from a single project with differing POM-defined dependencies?


(Luke Daley) #5

There is probably a bigger issue here too. I cannot see a way to define distinct POMs for the ‘jar’ and ‘testing’ artifacts (the testing artifact requires additional transitive dependencies).

Correct, that’s not supported yet. It’s currently the third next story in the queue for the publication stream (https://github.com/gradle/gradle/blob/master/design-docs/publication-model.md#i-want-to-publish-multiple-ivy-or-maven-modules-from-my-project)

If you need to do this you’ll either have to use the old model, or use the XML modification hooks to hand craft it.


(steve) #6

Thanks for the reply Luke.

Is there a Jira I can watch/track for that? I do not see JIras related to the stories there.


(Luke Daley) #7

We don’t use JIRA to track features, only defects.

We are still working out how to best publicise progress on upcoming features.

For the time being you’ll just have to keep an eye on the release notes until we work something out.