Search in sources :

Example 1 with Attributes

use of org.gradle.api.java.archives.Attributes in project gradle by gradle.

the class DefaultOsgiManifest method getEffectiveManifest.

@Override
public DefaultManifest getEffectiveManifest() {
    ContainedVersionAnalyzer analyzer = analyzerFactory.create();
    DefaultManifest effectiveManifest = new DefaultManifest(null);
    try {
        setAnalyzerProperties(analyzer);
        Manifest osgiManifest = analyzer.calcManifest();
        java.util.jar.Attributes attributes = osgiManifest.getMainAttributes();
        for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
            effectiveManifest.attributes(WrapUtil.toMap(entry.getKey().toString(), (String) entry.getValue()));
        }
        effectiveManifest.attributes(this.getAttributes());
        for (Map.Entry<String, Attributes> ent : getSections().entrySet()) {
            effectiveManifest.attributes(ent.getValue(), ent.getKey());
        }
        if (classesDir != null) {
            long mod = classesDir.lastModified();
            if (mod > 0) {
                effectiveManifest.getAttributes().put(Analyzer.BND_LASTMODIFIED, mod);
            }
        }
    } catch (Exception e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
    return getEffectiveManifestInternal(effectiveManifest);
}
Also used : DefaultManifest(org.gradle.api.java.archives.internal.DefaultManifest) Attributes(org.gradle.api.java.archives.Attributes) Manifest(java.util.jar.Manifest) DefaultManifest(org.gradle.api.java.archives.internal.DefaultManifest) OsgiManifest(org.gradle.api.plugins.osgi.OsgiManifest) IOException(java.io.IOException) UncheckedException(org.gradle.internal.UncheckedException)

Example 2 with Attributes

use of org.gradle.api.java.archives.Attributes in project spring-boot by spring-projects.

the class BootArchiveSupport method configureManifest.

void configureManifest(Manifest manifest, String mainClass, String classes, String lib, String classPathIndex, String layersIndex) {
    Attributes attributes = manifest.getAttributes();
    attributes.putIfAbsent("Main-Class", this.loaderMainClass);
    attributes.putIfAbsent("Start-Class", mainClass);
    attributes.computeIfAbsent("Spring-Boot-Version", (name) -> determineSpringBootVersion());
    attributes.putIfAbsent("Spring-Boot-Classes", classes);
    attributes.putIfAbsent("Spring-Boot-Lib", lib);
    if (classPathIndex != null) {
        attributes.putIfAbsent("Spring-Boot-Classpath-Index", classPathIndex);
    }
    if (layersIndex != null) {
        attributes.putIfAbsent("Spring-Boot-Layers-Index", layersIndex);
    }
}
Also used : Attributes(org.gradle.api.java.archives.Attributes)

Aggregations

Attributes (org.gradle.api.java.archives.Attributes)2 IOException (java.io.IOException)1 Manifest (java.util.jar.Manifest)1 DefaultManifest (org.gradle.api.java.archives.internal.DefaultManifest)1 OsgiManifest (org.gradle.api.plugins.osgi.OsgiManifest)1 UncheckedException (org.gradle.internal.UncheckedException)1