Skip to content

Commit

Permalink
close #66, use PatternSet instead of CopySpecInternal
Browse files Browse the repository at this point in the history
  • Loading branch information
johnrengelman committed Jul 2, 2014
1 parent d046d66 commit fddc23a
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,19 @@ import org.apache.commons.io.FilenameUtils
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ResolvedDependency
import org.gradle.api.internal.file.copy.CopySpecInternal
import org.gradle.api.specs.Spec
import org.gradle.api.specs.Specs
import org.gradle.api.tasks.util.PatternSet

class DependencyFilter {

private final Project project
private final CopySpecInternal mainSpec
private final PatternSet patternSet

DependencyFilter(Project project) {
assert project
this.project = project
this.mainSpec = (CopySpecInternal) project.copySpec {}
}

public PatternSet getPatternSet() {
mainSpec.getPatternSet()
this.patternSet = new PatternSet()
}

/**
Expand All @@ -34,7 +29,7 @@ class DependencyFilter {
Set<ResolvedDependency> dependencies = findMatchingDependencies(spec,
project.configurations.runtime.resolvedConfiguration.firstLevelModuleDependencies)
dependencies.collect { it.moduleArtifacts.file }.flatten().each { File file ->
this.mainSpec.exclude(FilenameUtils.getName(file.path))
this.patternSet.exclude(FilenameUtils.getName(file.path))
}
return this
}
Expand All @@ -45,15 +40,19 @@ class DependencyFilter {
* @param spec
* @return
*/
public DependencyFilter include(Spec<? super ResolvedDependency> spec, boolean includeTransitive = true) {
public DependencyFilter include(Spec<? super ResolvedDependency> spec) {
Set<ResolvedDependency> dependencies = findMatchingDependencies(spec,
project.configurations.runtime.resolvedConfiguration.firstLevelModuleDependencies)
dependencies.collect { it.moduleArtifacts.file }.flatten().each { File file ->
this.mainSpec.include(FilenameUtils.getName(file.path))
this.patternSet.include(FilenameUtils.getName(file.path))
}
return this
}

public PatternSet getPatternSet() {
return patternSet
}

/**
* Create a spec that matches the provided project notation on group, name, and version
* @param notation
Expand Down

0 comments on commit fddc23a

Please sign in to comment.