Skip to content

Commit

Permalink
issue #76: use only dependencies on other projects
Browse files Browse the repository at this point in the history
  • Loading branch information
siordache committed Aug 25, 2019
1 parent df08755 commit 9227aa8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import org.beryx.jlink.data.PrepareMergedJarsDirTaskData
import org.beryx.jlink.impl.PrepareMergedJarsDirTaskImpl
import org.beryx.jlink.util.JavaVersion
import org.beryx.jlink.util.PathUtil
import org.beryx.jlink.util.Util
import org.gradle.api.Task
import org.gradle.api.file.Directory
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.*
Expand Down Expand Up @@ -59,9 +61,12 @@ class PrepareMergedJarsDirTask extends BaseTask {


PrepareMergedJarsDirTask() {
def jarTasks = project.rootProject.getTasksByName('jar', true).toArray()
dependsOn(jarTasks)
description = 'Merges all non-modularized jars into a single module'
project.afterEvaluate {
def projects = Util.getAllDependentProjects(project) + project
def jarTasks = projects*.getTasksByName('jar', true).flatten() as Task[]
dependsOn(jarTasks)
}
}

@TaskAction
Expand Down
8 changes: 8 additions & 0 deletions src/main/groovy/org/beryx/jlink/util/Util.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.codehaus.groovy.runtime.IOGroovyMethods
import org.codehaus.groovy.tools.Utilities
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.ResolvedDependency
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
Expand Down Expand Up @@ -343,4 +344,11 @@ class Util {
}
null
}

static List<Project> getAllDependentProjects(Project project) {
def projectDependencies = project.configurations*.dependencies*.withType(ProjectDependency).flatten() as Set<ProjectDependency>
List<Project> dependentProjects = projectDependencies*.dependencyProject
dependentProjects.each { dependentProjects += getAllDependentProjects(it) }
return dependentProjects.unique()
}
}

0 comments on commit 9227aa8

Please sign in to comment.