@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); }
@Override public DefaultManifest getEffectiveManifest() { Attributes attributes = getAttributes(); String keyname = (String)attributes.get("keyname"); if (keyname==null || keyname.isEmpty()) { throw new ManifestException("keyname needs to be set before getting effective manifest"); } attributes.put("componentelement", ComponentElementHelper.generate(attributes)); // System.out.println("SAPManifest.getEffectiveManifest~includeDependencies:" +includeDependencies); // System.out.println("SAPManifest.getEffectiveManifest~applicationJ2eeEngineFile:" +applicationJ2eeEngineFile); boolean hasDependencies = false; if (includeDependencies && applicationJ2eeEngineFile!=null) { //deferred application-j2ee-engine.xml parse final ApplicationJ2eeEngineHelper applicationJ2eeEngineHelper = new ApplicationJ2eeEngineHelper(); applicationJ2eeEngineHelper.setSourceFile(applicationJ2eeEngineFile).parse(); hasDependencies = applicationJ2eeEngineHelper.hasReferences(); if (hasDependencies) { String dependencies = applicationJ2eeEngineHelper.toDependencies().toString(); attributes.put("dependencies", ManifestStringSplitter.splitIt(dependencies)); //System.out.println(ManifestStringSplitter.splitIt(dependencies)); String dependencyList = applicationJ2eeEngineHelper.toDependencyList().toString(); attributes.put("dependencyList", ManifestStringSplitter.splitIt(dependencyList)); //System.out.println(ManifestStringSplitter.splitIt(dependencyList)); } } if (!hasDependencies) { attributes.remove("dependencies"); attributes.remove("dependencyList"); } //System.out.println("SAPManifest.getEffectiveManifest() - attributes.get("componentelement")); return super.getEffectiveManifest(); }
@Override public DefaultManifest writeTo(Writer writer) { Attributes attributes = getEffectiveManifest().getAttributes(); PrintWriter printWriter = new PrintWriter(writer); for (Map.Entry<String, Object> entry : attributes.entrySet()) { printWriter.println(entry.getKey() + ": " + entry.getValue()); } printWriter.println(); printWriter.flush(); return this; }
/** * Creates and configures a new instance of a {@link Manifest}. The given closure configures * the new manifest instance before it is returned. * * @param closure The closure to use to configure the manifest. */ public Manifest manifest(Closure closure) { return ConfigureUtil.configure(closure, new DefaultManifest(project.getFileResolver())); }