mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
[gradle] Added configuration for bundle manifests
Signed-off-by: Miro Spönemann <miro.spoenemann@typefox.io>
This commit is contained in:
parent
95dc78d200
commit
13225035d5
4 changed files with 77 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
|||
ext.buildTime = new java.text.SimpleDateFormat('yyyyMMddHHmm').format(new Date())
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
|
@ -8,6 +10,7 @@ subprojects {
|
|||
apply from: "${rootDir}/gradle/eclipse-project-layout.gradle"
|
||||
apply from: "${rootDir}/gradle/java-compiler-settings.gradle"
|
||||
apply from: "${rootDir}/gradle/maven-deployment.gradle"
|
||||
apply from: "${rootDir}/gradle/manifest-gen.gradle"
|
||||
|
||||
group = 'org.eclipse.xtext'
|
||||
}
|
||||
|
|
|
@ -25,9 +25,6 @@ jar {
|
|||
from ('.') {
|
||||
include 'about*.*', 'plugin.xml', 'schema/**', 'model/**'
|
||||
}
|
||||
metaInf {
|
||||
from 'META-INF'
|
||||
}
|
||||
}
|
||||
|
||||
if (isTestProject) {
|
||||
|
|
74
gradle/manifest-gen.gradle
Normal file
74
gradle/manifest-gen.gradle
Normal file
|
@ -0,0 +1,74 @@
|
|||
def baseVersion = project.version
|
||||
if (baseVersion.endsWith('-SNAPSHOT'))
|
||||
baseVersion = baseVersion.substring(0, baseVersion.length() - 9)
|
||||
|
||||
def limitLineLength = { line, output ->
|
||||
def firstLine = true
|
||||
while (line.length() > 70) {
|
||||
if (firstLine) {
|
||||
output.println(line.substring(0, 70))
|
||||
line = line.substring(70)
|
||||
firstLine = false
|
||||
} else {
|
||||
output.println(' ' + line.substring(0, 69))
|
||||
line = line.substring(69)
|
||||
}
|
||||
}
|
||||
if (firstLine)
|
||||
output.println(line)
|
||||
else
|
||||
output.println(' ' + line)
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// Copy the existing manifest and insert the qualifier
|
||||
|
||||
def manifestFile = "$buildDir/tmp/jar/MANIFEST.MF"
|
||||
|
||||
task genManifest(type: Copy) {
|
||||
from "META-INF/MANIFEST.MF"
|
||||
into "$buildDir/tmp/jar/"
|
||||
doLast {
|
||||
def f = new File(manifestFile)
|
||||
def modifiedText = f.text.replace(baseVersion + '.qualifier', baseVersion + '.' + buildTime)
|
||||
def writer = new PrintWriter(f)
|
||||
writer.print(modifiedText)
|
||||
writer.close()
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
dependsOn genManifest
|
||||
inputs.file(manifestFile)
|
||||
manifest {
|
||||
from manifestFile
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// Generate a manifest for the source bundle
|
||||
|
||||
def sourcesManifestFile = "$buildDir/tmp/sourcesJar/MANIFEST.MF"
|
||||
|
||||
task genSourcesManifest << {
|
||||
def f = new File(sourcesManifestFile)
|
||||
f.parentFile.mkdirs()
|
||||
def writer = new PrintWriter(f)
|
||||
limitLineLength('Manifest-Version: 1.0', writer)
|
||||
limitLineLength('Bundle-ManifestVersion: 2', writer)
|
||||
limitLineLength('Bundle-SymbolicName: ' + project.name + '.source', writer)
|
||||
limitLineLength('Bundle-Version: ' + baseVersion + '.' + buildTime, writer)
|
||||
limitLineLength('Bundle-Name: Sources', writer)
|
||||
limitLineLength('Bundle-Vendor: Eclipse Xtext', writer)
|
||||
limitLineLength('Eclipse-SourceBundle: ' + project.name + ';version="' + baseVersion + '.' + buildTime + '"', writer)
|
||||
writer.close()
|
||||
}
|
||||
genSourcesManifest.outputs.file(sourcesManifestFile)
|
||||
|
||||
sourcesJar {
|
||||
dependsOn genSourcesManifest
|
||||
inputs.file(sourcesManifestFile)
|
||||
manifest {
|
||||
from sourcesManifestFile
|
||||
}
|
||||
}
|
|
@ -7,9 +7,6 @@ task sourcesJar(type: Jar, dependsOn: classes) {
|
|||
from ('.') {
|
||||
include 'schema/**', 'model/**'
|
||||
}
|
||||
metaInf {
|
||||
from 'META-INF'
|
||||
}
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
|
|
Loading…
Reference in a new issue