List of usage examples for java.util.jar JarFile MANIFEST_NAME
String MANIFEST_NAME
To view the source code for java.util.jar JarFile MANIFEST_NAME.
Click Source Link
From source file:org.sourcepit.osgifier.core.packaging.Repackager.java
private static PathMatcher createJarContentMatcher(Collection<String> customPathFilters) { final Set<String> pathFilters = new HashSet<String>(); pathFilters.add("!" + JarFile.MANIFEST_NAME); // will be set manually pathFilters.add("!META-INF/*.SF"); pathFilters.add("!META-INF/*.DSA"); pathFilters.add("!META-INF/*.RSA"); if (customPathFilters != null) { pathFilters.addAll(customPathFilters); }/*from ww w . j ava 2 s . c o m*/ final String matcherPattern = toPathMatcherPattern(pathFilters); return PathMatcher.parse(matcherPattern, "/", ","); }
From source file:org.sourcepit.osgifier.maven.GenerateManifestMojo.java
private void write(final File dir, final BundleManifest manifest, final BundleLocalization localization) { final File manifestFile = new File(dir, JarFile.MANIFEST_NAME); writeModel(manifestFile, manifest);/* w ww .j a va2s . c om*/ if (localization != null) { try { BundleLocalizationWriter.write(dir, manifest, localization); } catch (IOException e) { throw pipe(e); } } }
From source file:org.talend.updates.runtime.nexus.component.ComponentIndexManager.java
/** * /* w w w . ja va2s . c om*/ * create one default index bean which based one the component zip file directly. * * bundleId, version, mvn_uri are required */ public ComponentIndexBean create(File componentZipFile) { if (componentZipFile == null || !componentZipFile.exists() || componentZipFile.isDirectory() || !componentZipFile.getName().endsWith(FileExtensions.ZIP_FILE_SUFFIX)) { return null; } String name = null; String bundleId = null; String bundleVersion = null; String mvnUri = null; ZipFile zipFile = null; try { zipFile = new ZipFile(componentZipFile); Enumeration<ZipEntry> enumeration = (Enumeration<ZipEntry>) zipFile.entries(); while (enumeration.hasMoreElements()) { final ZipEntry zipEntry = enumeration.nextElement(); String path = zipEntry.getName(); if (path.endsWith(FileExtensions.JAR_FILE_SUFFIX)) { // is jar // if it's bundle, not from other folder, like lib, m2 repository. IPath p = new Path(path); // must be in plugins if (p.segmentCount() > 1 && p.removeLastSegments(1).lastSegment().equals(UpdatesHelper.FOLDER_PLUGINS)) { if (UpdatesHelper.isComponentJar(zipFile.getInputStream(zipEntry))) { JarInputStream jarEntryStream = null; try { // must use another stream jarEntryStream = new JarInputStream(zipFile.getInputStream(zipEntry)); // find the bundleId and version Manifest manifest = jarEntryStream.getManifest(); if (manifest != null) { bundleId = JarMenifestUtil.getBundleSymbolicName(manifest); bundleVersion = JarMenifestUtil.getBundleVersion(manifest); } boolean checkManifest = StringUtils.isBlank(bundleId) || StringUtils.isBlank(bundleVersion); // find the pom.properties JarEntry jarEntry = null; while ((jarEntry = jarEntryStream.getNextJarEntry()) != null) { final String entryPath = jarEntry.getName(); if (checkManifest && JarFile.MANIFEST_NAME.equalsIgnoreCase(entryPath)) { manifest = new Manifest(); manifest.read(jarEntryStream); bundleId = JarMenifestUtil.getBundleSymbolicName(manifest); bundleVersion = JarMenifestUtil.getBundleVersion(manifest); checkManifest = false; } final Path fullPath = new Path(entryPath); final String fileName = fullPath.lastSegment(); /* * for example, * META-INF/maven/org.talend.components/components-splunk/pom.properties */ if (fileName.equals("pom.properties") //$NON-NLS-1$ && entryPath.contains("META-INF/maven/")) { //$NON-NLS-1$ // FIXME, didn't find one way to read the inner jar // final InputStream propStream = jarFile.getInputStream(jarEntry); // if (propStream != null) { // Properties pomProp = new Properties(); // pomProp.load(propStream); // // String version = pomProp.getProperty("version"); //$NON-NLS-1$ // String groupId = pomProp.getProperty("groupId"); //$NON-NLS-1$ // String artifactId = pomProp.getProperty("artifactId"); //$NON-NLS-1$ // mvnUri = MavenUrlHelper.generateMvnUrl(groupId, artifactId, version, // FileExtensions.ZIP_FILE_SUFFIX, null); // // propStream.close(); // } // FIXME, try the path way // META-INF/maven/org.talend.components/components-splunk IPath tmpMavenPath = fullPath.removeLastSegments(1); String artifactId = tmpMavenPath.lastSegment(); // components-splunk // META-INF/maven/org.talend.components tmpMavenPath = tmpMavenPath.removeLastSegments(1); String groupId = tmpMavenPath.lastSegment(); // org.talend.components mvnUri = MavenUrlHelper.generateMvnUrl(groupId, artifactId, bundleVersion, FileExtensions.ZIP_EXTENSION, null); } else /* * /OSGI-INF/installer$$splunk.xml */ if (fileName.endsWith(FileExtensions.XML_FILE_SUFFIX) && fileName.startsWith(UpdatesHelper.NEW_COMPONENT_PREFIX) && entryPath.contains(UpdatesHelper.FOLDER_OSGI_INF + '/')) { name = fullPath.removeFileExtension().lastSegment(); name = name.substring(name.indexOf(UpdatesHelper.NEW_COMPONENT_PREFIX) + UpdatesHelper.NEW_COMPONENT_PREFIX.length()); } } } catch (IOException e) { // } finally { try { if (jarEntryStream != null) { jarEntryStream.close(); } } catch (IOException e) { // } } } } } } } catch (ZipException e) { if (CommonsPlugin.isDebugMode()) { ExceptionHandler.process(e); } } catch (IOException e) { if (CommonsPlugin.isDebugMode()) { ExceptionHandler.process(e); } } finally { if (zipFile != null) { try { zipFile.close(); } catch (IOException e) { // } } } // set the required if (name != null && bundleId != null && bundleVersion != null && mvnUri != null) { final ComponentIndexBean indexBean = new ComponentIndexBean(); final boolean set = indexBean.setRequiredFieldsValue(name, bundleId, bundleVersion, mvnUri); indexBean.setValue(ComponentIndexNames.types, PathUtils.convert2StringTypes(Arrays.asList(Type.TCOMP_V0))); if (set) { return indexBean; } } return null; }
From source file:tilda.db.ConnectionPool.java
private static void LoadTildaResources(Connection C, boolean Migrate) throws Exception { Reader R = null;//from w w w. ja v a2s . c om InputStream In = null; Enumeration<URL> resEnum = ConnectionPool.class.getClassLoader().getResources(JarFile.MANIFEST_NAME); List<Schema> TildaList = new ArrayList<Schema>(); while (resEnum.hasMoreElements()) { URL url = (URL) resEnum.nextElement(); In = url.openStream(); if (In != null) { Manifest Man = new Manifest(); Man.read(In); In.close(); String Tildas = Man.getMainAttributes().getValue("Tilda"); if (TextUtil.isNullOrEmpty(Tildas) == false) { LOG.debug("Found Tilda(s) " + Tildas + " in " + url.toString()); String[] parts = Tildas.split(";"); if (parts != null) for (String p : parts) { if (TextUtil.isNullOrEmpty(p) == true) continue; p = p.trim(); In = FileUtil.getResourceAsStream(p); if (In == null) throw new Exception( "Tilda schema definition '" + p + "' could not be found in the classpath."); LOG.info("Inspecting " + p); R = new BufferedReader(new InputStreamReader(In)); Gson gson = new GsonBuilder().setPrettyPrinting().create(); Schema S = gson.fromJson(R, Schema.class); S.setOrigin(p); TildaList.add(S); In.close(); } } } } ReorderTildaListWithDependencies(TildaList); // LOG.debug("All Tildas in order of dependencies:"); // for (Schema S : TildaList) // LOG.debug(" "+S._ResourceNameShort); if (Migrate == false) Migrator.logMigrationWarning(); int warnings = 0; for (Schema S : TildaList) { int w = Migrator.migrate(C, S, Migrate); if (w != 0 && Migrate == false) { warnings += w; LOG.warn("There were " + w + " warning(s) issued because schema discrepencies were found but not fixed."); Migrator.logMigrationWarning(); continue; } LOG.debug("Initializing Schema objects"); Method M = Class.forName(tilda.generation.java8.Helper.getSupportClassFullName(S)) .getMethod("initSchema", Connection.class); M.invoke(null, C); _SchemaPackage.put(S._Name, S._Package); C.commit(); } LOG.debug(""); LOG.debug("Creating/updating Tilda helper stored procedures."); if (Migrate == false) Migrator.logMigrationWarning(); else if (C.addHelperFunctions() == false) throw new Exception("Cannot upgrade schema by adding the Tilda helper functions."); if (warnings != 0 && Migrate == false) { LOG.warn(""); LOG.warn(""); LOG.warn("There were a total of " + warnings + " warning(s) issued because schema discrepencies were found but not fixed."); Migrator.logMigrationWarning(); } C.commit(); }