diff --git a/geode-cq/build.gradle b/geode-cq/build.gradle index 3c2e12ea2087..57cbd5e43b76 100644 --- a/geode-cq/build.gradle +++ b/geode-cq/build.gradle @@ -21,7 +21,7 @@ apply from: "${project.projectDir}/../gradle/publish-java.gradle" dependencies { - compile(platform(project(':boms:geode-all-bom'))) + implementation(platform(project(':boms:geode-all-bom'))) implementation(project(':geode-core')) implementation(project(':geode-logging')) implementation(project(':geode-membership')) diff --git a/geode-lucene/build.gradle b/geode-lucene/build.gradle index 7f3b64ac8527..29ad720838b9 100644 --- a/geode-lucene/build.gradle +++ b/geode-lucene/build.gradle @@ -21,7 +21,7 @@ apply from: "${project.projectDir}/../gradle/publish-java.gradle" dependencies { - compile(platform(project(':boms:geode-all-bom'))) + api(platform(project(':boms:geode-all-bom'))) api(project(':geode-core')) api('org.apache.lucene:lucene-core') diff --git a/gradle/java.gradle b/gradle/java.gradle index 132f3ccbb3ae..2742511bb807 100644 --- a/gradle/java.gradle +++ b/gradle/java.gradle @@ -61,15 +61,58 @@ gradle.taskGraph.whenReady({ graph -> // apply default manifest gradle.taskGraph.whenReady({ graph -> tasks.withType(Jar).each { jar -> - jar.doFirst { - manifest { - attributes.put("Manifest-Version", "1.0") - attributes.put("Created-By", System.getProperty("user.name")) - attributes.put("Title", rootProject.name) - attributes.put("Version", version) - attributes.put("Organization", productOrg) + + def projectDependencies = [] + def runtimeList = [] + def allProjectDeps = [] + + def confList = ['api', 'implementation', 'runtimeOnly'] + confList.each { conf -> + allProjectDeps.addAll(project.configurations.getByName(conf).getDependencies()) + } + + // Iterate over runtime classpath dependencies and separate project dependencies from library + // dependencies. + allProjectDeps.each { dependency -> + if ( dependency instanceof ProjectDependency ) { + def platformAttribute = Attribute.of("org.gradle.category", org.gradle.api.attributes.Category.class) + def foundAttribute = dependency.attributes.getAttribute(platformAttribute) + if ( foundAttribute == null) { + projectDependencies.add(dependency) + } else if ('platform'.equals(foundAttribute)) { + projectDependencies.add(dependency) + } + } else { + project.configurations.runtimeClasspath.files(dependency).each { depJar -> + runtimeList.add(depJar.name) } } + } + + // Iterate over project (parent) dependencies and remove its runtime library dependencies from + // the current project's runtime library dependencies. + // Also removes all parent project's runtime project dependencies from the current project. + // This returns a unique set of parent project and library dependencies that are not found + // within it's parent's project dependencies. + projectDependencies.clone().each { ProjectDependency projectDependency -> + Project geodeProject = projectDependency.getDependencyProject() + def collect = geodeProject.configurations.runtimeClasspath.collect { it.name } + runtimeList.removeAll(collect) +// projectDependencies.removeAll(collect.collect {it-".jar"}) + } + + jar.doFirst { + manifest { + attributes.put("Manifest-Version", "1.0") + attributes.put("Created-By", System.getProperty("user.name")) + attributes.put("Title", rootProject.name) + attributes.put("Version", version) + attributes.put("Organization", productOrg) + attributes.put("Class-Path", runtimeList.join(' ')) + attributes.put("Dependent-Modules", projectDependencies.collect({ "${it.name}-${it.version}" }).join(' ')) + attributes.put("Module-Name", project.name) + } + } jar.metaInf { from("$rootDir/geode-assembly/src/main/dist/LICENSE") if (jar.source.filter({ it.name.contains('NOTICE') }).empty) { diff --git a/gradle/publish-java.gradle b/gradle/publish-java.gradle index 15db47f5f32c..3a47b6a5323d 100644 --- a/gradle/publish-java.gradle +++ b/gradle/publish-java.gradle @@ -28,50 +28,3 @@ publishing { } } } - -gradle.taskGraph.whenReady({ graph -> - tasks.withType(Jar).each { jar -> - jar.doFirst { - def projectDependencies = [] - def runtimeList = [] - - // Iterate over runtime classpath dependencies and separate project dependencies from library - // dependencies. - configurations.runtimeClasspath - .collect { it.name - ".jar" } - .each { dependency -> - if (dependency.startsWith("geode-")) { - projectDependencies.add(dependency) - } else { - runtimeList.add(dependency+".jar") - } - } - - // Iterate over project (parent) dependencies and remove its runtime library dependencies from - // the current project's runtime library dependencies. - // Also removes all parent project's runtime project dependencies from the current project. - // This returns a unique set of parent project and library dependencies that are not found - // within it's parent's project dependencies. - projectDependencies.clone().each { projectDependency -> - def geodeProject = projectDependency - "-${version}.jar" - if (projectDependencies.contains(geodeProject)) { - try { - def parentProject = project(":$geodeProject" - "-$version") - def collect = parentProject.configurations.runtimeClasspath.collect { it.name } - runtimeList.removeAll(collect) - projectDependencies.removeAll(collect.collect {it-".jar"}) - } catch (UnknownProjectException ignore) { - } - } - } - - manifest { - attributes.put("Class-Path", runtimeList.join(' ')) - attributes.put("Dependent-Modules", projectDependencies.join(' ')) - attributes.put("Module-Name", project.name) - } - } - } -}) - -