xtext-core/gradle/validation.gradle

36 lines
807 B
Groovy
Raw Permalink Normal View History

/*
* Validation of output artifacts to make sure they can be published.
*/
import java.util.jar.JarFile
def checkDuplicateEntries = { archive ->
def uniqueEntries = new HashSet()
def jarFile = new JarFile(archive)
def entries = jarFile.entries()
while (entries.hasMoreElements()) {
def entry = entries.nextElement()
if (!uniqueEntries.add(entry.name))
throw new GradleException("Duplicate entry ${entry} in archive ${archive.name}")
}
jarFile.close()
}
task validateJar {
dependsOn(jar)
inputs.file(jar.archivePath)
doLast {
checkDuplicateEntries(jar.archivePath)
}
}
check.dependsOn(validateJar)
task validateSourcesJar {
dependsOn(sourcesJar)
inputs.file(sourcesJar.archivePath)
doLast {
checkDuplicateEntries(sourcesJar.archivePath)
}
}
check.dependsOn(validateSourcesJar)