mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
Implemented validation of duplicate jar entries
This commit is contained in:
parent
b97a5ed574
commit
be55c347df
3 changed files with 41 additions and 2 deletions
|
@ -15,6 +15,7 @@ subprojects {
|
||||||
apply from: "${rootDir}/gradle/maven-deployment.gradle"
|
apply from: "${rootDir}/gradle/maven-deployment.gradle"
|
||||||
apply from: "${rootDir}/gradle/eclipse-project-layout.gradle"
|
apply from: "${rootDir}/gradle/eclipse-project-layout.gradle"
|
||||||
apply from: "${rootDir}/gradle/manifest-gen.gradle"
|
apply from: "${rootDir}/gradle/manifest-gen.gradle"
|
||||||
|
apply from: "${rootDir}/gradle/validation.gradle"
|
||||||
|
|
||||||
group = 'org.eclipse.xtext'
|
group = 'org.eclipse.xtext'
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,13 @@ def sourceDirs = ['src', 'xtend-gen', 'src-gen', 'emf-gen']
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
configure(isTestProject? test : main) {
|
configure(isTestProject? test : main) {
|
||||||
java.srcDirs = sourceDirs
|
java {
|
||||||
|
srcDirs = sourceDirs
|
||||||
|
include '**/*.java', '**/*.xtend'
|
||||||
|
}
|
||||||
resources {
|
resources {
|
||||||
srcDirs = sourceDirs
|
srcDirs = sourceDirs
|
||||||
exclude '**/*.java', '**/*.xtendbin', '**/*.xtend', '**/*._trace'
|
exclude '**/*.java', '**/*.xtend', '**/*.xtendbin', '**/*._trace'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
configure(isTestProject? main : test) {
|
configure(isTestProject? main : test) {
|
||||||
|
|
35
gradle/validation.gradle
Normal file
35
gradle/validation.gradle
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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)
|
Loading…
Reference in a new issue