Skip to content
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

Added additional functionality #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
153 changes: 76 additions & 77 deletions src/main/groovy/com/admc/gradle/GradleUtil.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,82 +6,81 @@ import org.gradle.api.artifacts.DependencyArtifact
import java.util.regex.Pattern

class GradleUtil {
/**
* Throws if any dependencies of the specified Configuration are not
* satisfied.
*
* Has some limitations, so study the output if it throws.
* One limitation is that if an exclude directive correctly eliminates an
* artifact, this method won't know about it.
*
* @throws GradleException containing list of non-satisfied dependencies
*/
static final private Pattern variableVersionPattern =
Pattern.compile('.*[^-\\w.].*')
/**
* Throws if any dependencies of the specified Configuration are not
* satisfied.
*
* Has some limitations, so study the output if it throws.
* One limitation is that if an exclude directive correctly eliminates an
* artifact, this method won't know about it.
*
* @throws GradleException containing list of non-satisfied dependencies
*/
static final private Pattern variableVersionPattern =
Pattern.compile('.*[^-\\w.].*')

static void verifyResolve(config) {
Set<String> artifactSet = [] as Set
String classifierStr
boolean satisfied
List<ModuleDependency> unsatisfiedDeps = []
List<DependencyArtifact> unsatisfiedArts = []
config.allDependencies.each { it.artifacts.each {
// The ModuleDependencies only have artifict members if either
// classifier or extension/type are specified for the dependency.
// If neither is, then we'll check the dependency in the findAll
// loop below.
DependencyArtifact depArt ->
classifierStr =
(depArt.classifier == null) ? '' : ('-' + depArt.classifier)
Pattern pat = Pattern.compile(
depArt.name + '-.+' + classifierStr + '.' + depArt.extension)
satisfied = false
for (File f in config.files) {
if (pat.matcher(f.name).matches()) {
satisfied = true
break
}
}
if (!satisfied) {
unsatisfiedDeps << it
unsatisfiedArts << depArt
}
} }
config.allDependencies.findAll { it.artifacts.size() == 0 }.each {
ModuleDependency dep ->
String depString = (dep.version.indexOf('SNAPSHOT') > -1
|| GradleUtil.variableVersionPattern.matcher(dep.version)
.matches()) ? '' : dep.version
Pattern pat = Pattern.compile(
'\\Q' + dep.name + '-' + depString + '\\E' + '[.-].+')
satisfied = false
for (File f in config.files) {
if (pat.matcher(f.name).matches()) {
satisfied = true
break
}
}
if (!satisfied) {
unsatisfiedDeps << dep
unsatisfiedArts << null
}
}
if (unsatisfiedDeps.size() == 0) return
StringBuilder sb = new StringBuilder()
DependencyArtifact depArt
int oneBasedInt
unsatisfiedDeps.eachWithIndex{ ModuleDependency dep, int i ->
depArt = unsatisfiedArts[i]
sb.append(' ').append(i + 1)
sb.append(": $dep.group:$dep.name:$dep.version")
if (depArt != null) {
sb.append(' ARTIFACT: ').append("$depArt.name $depArt.extension")
if (depArt.classifier != null)
sb.append(" (classifier '$depArt.classifier')")
}
sb.append('\n')
}
throw new GradleException(
"Unsatisfied dependencies for configuration '$config.name':\n" + sb)
}
static void verifyResolve(config) {
Set<String> artifactSet = []as Set
String classifierStr
boolean satisfied
List<ModuleDependency> unsatisfiedDeps = []
List<DependencyArtifact> unsatisfiedArts = []
config.allDependencies.each {
it.artifacts.each { // The ModuleDependencies only have artifict members if either
// classifier or extension/type are specified for the dependency.
// If neither is, then we'll check the dependency in the findAll
// loop below.
DependencyArtifact depArt ->
classifierStr =
(depArt.classifier == null) ? '' : ('-' + depArt.classifier)
Pattern pat = Pattern.compile(
depArt.name + '-.+' + classifierStr + '.' + depArt.extension)
satisfied = false
for (File f in config.files) {
if (pat.matcher(f.name).matches()) {
satisfied = true
break
}
}
if (!satisfied) {
unsatisfiedDeps << it
unsatisfiedArts << depArt
}
} }
config.allDependencies.findAll { it.artifacts.size() == 0 }.each { ModuleDependency dep ->
String depString = (dep.version.indexOf('SNAPSHOT') > -1
|| GradleUtil.variableVersionPattern.matcher(dep.version)
.matches()) ? '' : dep.version
Pattern pat = Pattern.compile(
'\\Q' + dep.name + '-' + depString + '\\E' + '[.-].+')
satisfied = false
for (File f in config.files) {
if (pat.matcher(f.name).matches()) {
satisfied = true
break
}
}
if (!satisfied) {
unsatisfiedDeps << dep
unsatisfiedArts << null
}
}
if (unsatisfiedDeps.size() == 0) return
StringBuilder sb = new StringBuilder()
DependencyArtifact depArt
int oneBasedInt
unsatisfiedDeps.eachWithIndex{ ModuleDependency dep, int i ->
depArt = unsatisfiedArts[i]
sb.append(' ').append(i + 1)
sb.append(": $dep.group:$dep.name:$dep.version")
if (depArt != null) {
sb.append(' ARTIFACT: ').append("$depArt.name $depArt.extension")
if (depArt.classifier != null)
sb.append(" (classifier '$depArt.classifier')")
}
sb.append('\n')
}
throw new GradleException(
"Unsatisfied dependencies for configuration '$config.name':\n" + sb)
}
}
Loading