Skip to content

Move dependency report logic to the dist project #1489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ apply plugin: 'es.hadoop.build.root'

defaultTasks 'build'

allprojects {
group = "org.elasticsearch"
}

// Simple utility task to help with downloading artifacts and jars
if (project.hasProperty("find-artifact")) {
String artifact = project.getProperty("find-artifact")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.elasticsearch.hadoop.gradle

import org.elasticsearch.gradle.DependenciesInfoTask
import org.elasticsearch.gradle.DependenciesInfoPlugin
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
import org.elasticsearch.gradle.precommit.LicenseHeadersTask
Expand All @@ -12,7 +12,6 @@ import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.DependencyResolveDetails
import org.gradle.api.artifacts.DependencySubstitutions
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.ResolutionStrategy
Expand All @@ -24,7 +23,6 @@ import org.gradle.api.file.CopySpec
import org.gradle.api.file.FileCollection
import org.gradle.api.java.archives.Manifest
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.MavenPlugin
import org.gradle.api.plugins.MavenPluginConvention
import org.gradle.api.plugins.scala.ScalaPlugin
Expand Down Expand Up @@ -559,14 +557,7 @@ class BuildPlugin implements Plugin<Project> {

private static void configureDependenciesInfo(Project project) {
if (!project.path.startsWith(":qa")) {
project.tasks.register("dependenciesInfo", DependenciesInfoTask) { DependenciesInfoTask task ->
task.runtimeConfiguration = project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
task.compileOnlyConfiguration = project.configurations.getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME)
// Create a property called mappings that points to the same mappings in the dependency licenses task.
task.getConventionMapping().map('mappings') {
(project.tasks.getByName('dependencyLicenses') as DependencyLicensesTask).mappings
}
}
project.getPluginManager().apply(DependenciesInfoPlugin.class)
}
}
}
20 changes: 19 additions & 1 deletion dist/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.elasticsearch.gradle.ConcatFilesTask
import org.elasticsearch.gradle.DependenciesInfoTask

apply plugin: 'es.hadoop.build'

Expand All @@ -10,6 +12,13 @@ configurations {
canBeConsumed = false
transitive = false
}
javadocDependencies {
canBeResolved = true
canBeConsumed = false
}
compileClasspath {
extendsFrom javadocDependencies
}
dist {
canBeResolved = true
canBeConsumed = false
Expand All @@ -26,7 +35,7 @@ distProjects.each { distProject ->
// This is only going to pull in each project's regular jar to create the project-wide uberjar.
embedded(project(distProject))
// To squash Javadoc warnings.
compileOnly(project(distProject))
javadocDependencies(project(distProject))
// This will pull all java sources (including generated) for the project-wide javadoc.
javadocSources(project(distProject))
// This will pull all non-generated sources for the project-wide source jar.
Expand Down Expand Up @@ -128,3 +137,12 @@ task('distZip', type: Zip) {
distribution {
dependsOn(distZip)
}

// Add a task in the root project that collects all the dependencyReport data for each project
// Concatenates the dependencies CSV files into a single file
task generateDependenciesReport(type: ConcatFilesTask) {
dependsOn rootProject.allprojects.collect { it.tasks.withType(DependenciesInfoTask) }
files = fileTree(dir: project.rootDir, include: '**/dependencies.csv' )
headerLine = "name,version,url,license"
target = new File(System.getProperty('csv')?: "${project.buildDir}/reports/dependencies/es-hadoop-dependencies.csv")
}