subprojects {
    apply plugin: 'java'
    apply plugin: 'ivy-publish'

    repositories {
        mavenCentral()
    }

    publishing {
        repositories {
            ivy {
                url = "${rootProject.buildDir}/repo" // change to point to your repo, e.g. http://my.org/repo
            }
        }
    }
}

project(':project1') {
    dependencies {
       compile 'junit:junit:4.12'
    }


    // tag::customize-identity[]
    publishing {
        publications {
            ivy(IvyPublication) {
                organisation = 'org.gradle.sample'
                module = 'project1-sample'
                revision = '1.1'
                descriptor.status = 'milestone'
                descriptor.branch = 'testing'
                descriptor.extraInfo 'http://my.namespace', 'myElement', 'Some value'

                from components.java
            }
        }
    }
    // end::customize-identity[]
}

project(':project2') {
    // tag::multiple-publications[]
    task apiJar(type: Jar) {
        baseName = 'publishing-api'
        from sourceSets.main.output
        exclude '**/impl/**'
    }
    // end::multiple-publications[]

    dependencies {
       compile 'commons-collections:commons-collections:3.2.2', project(':project1')
    }

    // tag::multiple-publications[]
    publishing {
        publications {
            impl(IvyPublication) {
                organisation = 'org.gradle.sample.impl'
                module = 'project2-impl'
                revision = '2.3'

                from components.java
            }
            api(IvyPublication) {
    // end::multiple-publications[]
                configurations {
                    'default' {
                        extend 'compile'
                    }
                    compile {}
                }
                artifact(apiJar) {
                    conf = 'compile'
                }

    // tag::multiple-publications[]
                organisation = 'org.gradle.sample'
                module = 'project2-api'
                revision = '2'
            }
        }
    }
    // end::multiple-publications[]
}
