Quello che sto cercando di fare è combinare sia un file manifest.mf pre-creato dal mio progetto con il file manifest creato dinamicamente dall'attività jar in gradle.Gradle Manifest.MF
C'è un modo per farlo? Attualmente sto generando i miei file manifesto del tutto: -
jar.doFirst {
manifest {
def requiredProjects = ''
configurations.compile.getAllDependencies().withType(ProjectDependency).each {dep->
def dependantProjects = dep.getDependencyProject()
def projects = project(dependantProjects.path).libsDir.list().findAll{it.endsWith('.jar')}
projects.removeAll(projects.findAll{it.endsWith('test.jar')})
def requiredProject = projects.join(' ')
requiredProjects += requiredProject.replaceAll(/ /,'%20') + ' '
logger.info 'Required Project: ' + requiredProject
}
logger.info 'Required requiredProjects: ' + requiredProjects
def compileFiles = configurations.compile.files{ it instanceof ExternalDependency }.collect {
File file = it
"lib/${file.name}"
}.join(' ')
def manifestPath = requiredProjects + compileFiles
logger.info 'Manifest: '+ manifestPath
attributes 'Class-Path': manifestPath
attributes 'Build-date': new Date();
attributes 'Application-Version': project.version
}
}
so che avrò un file /META-INF/MANIFEST.MF.
Originariamente stavo usando il plugin OSGI per Gradle, ma questo sembra ignorare il file manifest e generare un gran casino.
Modifica
Ho guardato in questo un bel po ', grazie a Carlo ho trovato il seguente codice mi permette di leggere un MANIFEST.MF esistente: -
jar {
onlyIf { !compileJava.source.empty }
manifest {
// benutze das im Projekt vorliegende File, falls vorhanden:
def manif = "${projectDir}/META-INF/MANIFEST.MF"
if (new File(manif).exists()) {
from (manif) {
eachEntry { details ->
if (details.key == 'Bundle-Vendor') {
details.value = 'xyz GmbH'
}
}
}
}
else {
logger.info(project.name + " doesn't have a META-INF/MANIFEST.MF.")
manifest.attributes provider: xyz GmbH'
manifest.attributes project: project.name
manifest.attributes Build: new Date()
}
}
// copy if we have these:
from file ('plugin.xml')
from file ('plugin.properties')
into ('icons') { // if any ...
from fileTree('icons')
}
}
http://forums.gradle.org/gradle/topics/how_to_deal_with_eclipse_projects_and_manifest_files
Ho anche trovato un progetto chiamato "wuff" che mira a contribuire alla creazione di progetti OSGi con Gradle.
https://github.com/akhikhl/wuff