diff --git a/build.gradle b/build.gradle index 119910ed..c53b6648 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,7 @@ plugins { id 'maven' id 'org.ajoberstar.git-publish' version '3.0.0' id 'nebula.release' version '15.2.0' + id 'com.github.johnrengelman.shadow' version '5.2.0' apply false } group 'com.emc.ecs' diff --git a/bundle/build.gradle b/bundle/build.gradle new file mode 100644 index 00000000..0e7adce7 --- /dev/null +++ b/bundle/build.gradle @@ -0,0 +1,125 @@ +plugins { + id 'java' + id 'signing' + id 'maven-publish' + id 'com.github.johnrengelman.shadow' +} + +group = rootProject.group +description = rootProject.description + +repositories { + mavenCentral() + mavenLocal() +} + +dependencies { + // Let user use this dependencies + shadow 'org.slf4j:slf4j-api:1.7.32' + shadow 'commons-logging:commons-logging:1.2' + implementation(rootProject) { + // used for Jackson + exclude group: 'jakarta.xml.bind' + exclude group: 'jakarta.activation' + // used for jersey-json + exclude group: 'javax.xml.bind' + exclude group: 'com.sun.xml.bind' + exclude group: 'javax.activation' + // log + exclude group: 'org.slf4j' + exclude group: 'commons-logging' + } +} + +shadowJar { + archiveClassifier = null + def r = { String p -> relocate(p, 'com.emc.object.shadow.' + p) } + r 'com.fasterxml' + r 'com.sun.jersey' + r 'com.sun.ws.rs' + r 'com.sun.istack' + r 'javax.ws.rs' + r 'org.apache.commons.codec' + r 'org.apache.http' + r 'org.codehaus.jettison' + r 'org.dom4j' + r 'SevenZip' + + mergeServiceFiles() +} + +jar { + enabled = false +} + +publishing { + publications { + mavenJava(MavenPublication) { p -> + project.shadow.component(p) + artifact tasks.getByPath(":javadocJar") + artifact tasks.getByPath(":sourcesJar") + pom { + name = project.name + description = project.description + url = githubProjectUrl + + scm { + url = githubProjectUrl + connection = githubScmUrl + developerConnection = githubScmUrl + } + + licenses { + license { + name = licenseName + url = licenseUrl + distribution = 'repo' + } + } + + developers { + developer { + id = 'EMCECS' + name = 'Dell EMC ECS' + } + } + } + } + } + repositories { + maven { + url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + credentials { + username = rootProject.property("sonatypeUser") + password = rootProject.property("sonatypePass") + } + } + } +} + +signing { + sign publishing.publications.mavenJava +} + +/** + * The unit test task is to verify bundled jar. + */ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +task shadowTestJar(type: ShadowJar) { + archiveClassifier = "tests" + from rootProject.sourceSets.test.output + configurations = [] + relocators = shadowJar.relocators +} + +test { + // add original unit tests + testClassesDirs = rootProject.test.testClassesDirs + // shadow test files + classpath = tasks.shadowTestJar.outputs.files + + // original runtime class path without shadowed dependencies + (rootProject.configurations.testRuntimeClasspath - shadowJar.includedDependencies) + + // shadow jar + shadowJar.outputs.files +} \ No newline at end of file diff --git a/geo-pin-cli/build.gradle b/geo-pin-cli/build.gradle index df5efe28..54f53aa9 100644 --- a/geo-pin-cli/build.gradle +++ b/geo-pin-cli/build.gradle @@ -27,7 +27,7 @@ plugins { id 'java' id 'application' - id 'com.github.johnrengelman.shadow' version '5.2.0' + id 'com.github.johnrengelman.shadow' } group 'com.emc.ecs' diff --git a/settings.gradle b/settings.gradle index cd9eb98c..3def42ae 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,4 @@ rootProject.name = 'object-client' include 'geo-pin-cli' +include 'bundle' +project(":bundle").name = 'object-client-bundle'