protected String getName(Jar jar) throws Exception { String name = jar.getBsn(); if (name == null) { name = jar.getName(); if (name.equals("dot") && jar.getSource() != null) name = jar.getSource() .getName(); } String version = jar.getVersion(); if (version == null) version = "0.0.0"; return name + "-" + version; }
protected static StringBuilder dumpClasspath( List<Jar> classpath, StringBuilder buf ) { try { buf.append("#-----------------------------------------------------------------------" + NL); buf.append( "-classpath:\\" + NL ); for ( Iterator<Jar> i = classpath.iterator(); i.hasNext(); ) { File path = i.next().getSource(); if ( path != null ) { buf.append( ' ' + path.toString() + ( i.hasNext() ? ",\\" : "" ) + NL ); } } buf.append( "#-----------------------------------------------------------------------" + NL ); } catch ( Throwable e ) { // ignore... } return buf; }
protected String getName(Jar jar) throws Exception { String name = jar.getBsn(); if (name == null) { name = jar.getName(); if (name.equals("dot") && jar.getSource() != null) name = jar.getSource() .getName(); } String version = jar.getVersion(); if (version == null) version = "0.0.0"; return name + "-" + version; }
/** * Try to get a Jar from a file name/path or a url, or in last resort from * the classpath name part of their files. * * @param name * URL or filename relative to the base * @param from * Message identifying the caller for errors * @return null or a Jar with the contents for the name */ public Jar getJarFromName(String name, String from) { Jar j = super.getJarFromName(name, from); if (j == null) { for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) { Jar entry = cp.next(); if (entry.getSource() != null && entry.getSource().getName().equals(name)) { return entry; } } } return j; }
/** * Try to get a Jar from a file name/path or a url, or in last resort from * the classpath name part of their files. * * @param name * URL or filename relative to the base * @param from * Message identifying the caller for errors * @return null or a Jar with the contents for the name */ public Jar getJarFromName(String name, String from) { Jar j = super.getJarFromName(name, from); if (j == null) { for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) { Jar entry = cp.next(); if (entry.getSource() != null && entry.getSource().getName().equals(name)) { return entry; } } } return j; }
public List<Jar> getJarsFromName(String name, String from) { Jar j = super.getJarFromName(name, from); if (j != null) return Collections.singletonList(j); Glob g = new Glob(name); List<Jar> result = new ArrayList<>(); for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) { Jar entry = cp.next(); if (entry.getSource() == null) continue; if (g.matcher(entry.getSource() .getName()) .matches()) { result.add(entry); } } return result; }
public List<Jar> getJarsFromName(String name, String from) { Jar j = super.getJarFromName(name, from); if (j != null) return Collections.singletonList(j); Glob g = new Glob(name); List<Jar> result = new ArrayList<>(); for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) { Jar entry = cp.next(); if (entry.getSource() == null) continue; if (g.matcher(entry.getSource() .getName()) .matches()) { result.add(entry); } } return result; }
/** * Answer the string of the resource that it has in the container. It is * possible that the resource is a classpath entry. In that case an empty * string is returned. * * @param resource * The resource to look for * @return A suffix on the classpath or "" if the resource is a class path * entry * @throws Exception */ public String getClasspathEntrySuffix(File resource) throws Exception { for (Jar jar : getClasspath()) { File source = jar.getSource(); if (source != null) { source = source.getCanonicalFile(); String sourcePath = source.getAbsolutePath(); String resourcePath = resource.getAbsolutePath(); if (sourcePath.equals(resourcePath)) return ""; // Matches a classpath entry if (resourcePath.startsWith(sourcePath)) { // Make sure that the path name is translated correctly // i.e. on Windows the \ must be translated to / String filePath = resourcePath.substring(sourcePath.length() + 1); return filePath.replace(File.separatorChar, '/'); } } } return null; }
/** * Answer the string of the resource that it has in the container. It is * possible that the resource is a classpath entry. In that case an empty * string is returned. * * @param resource * The resource to look for * @return A suffix on the classpath or "" if the resource is a class path * entry * @throws Exception */ public String getClasspathEntrySuffix(File resource) throws Exception { for (Jar jar : getClasspath()) { File source = jar.getSource(); if (source != null) { source = source.getCanonicalFile(); String sourcePath = source.getAbsolutePath(); String resourcePath = resource.getAbsolutePath(); if (sourcePath.equals(resourcePath)) return ""; // Matches a classpath entry if (resourcePath.startsWith(sourcePath)) { // Make sure that the path name is translated correctly // i.e. on Windows the \ must be translated to / String filePath = resourcePath.substring(sourcePath.length() + 1); return filePath.replace(File.separatorChar, '/'); } } } return null; }
/** * Answer the string of the resource that it has in the container. It is * possible that the resource is a classpath entry. In that case an empty * string is returned. * * @param resource * The resource to look for * @return A suffix on the classpath or "" if the resource is a class path * entry * @throws Exception */ public String getClasspathEntrySuffix(File resource) throws Exception { for (Jar jar : getClasspath()) { File source = jar.getSource(); if (source != null) { source = source.getCanonicalFile(); String sourcePath = source.getAbsolutePath(); String resourcePath = resource.getAbsolutePath(); if (sourcePath.equals(resourcePath)) return ""; // Matches a classpath entry if (resourcePath.startsWith(sourcePath)) { // Make sure that the path name is translated correctly // i.e. on Windows the \ must be translated to / String filePath = resourcePath.substring(sourcePath.length() + 1); return filePath.replace(File.separatorChar, '/'); } } } return null; }
/** * Try to get a Jar from a file name/path or a url, or in last resort from * the classpath name part of their files. * * @param name URL or filename relative to the base * @param from Message identifying the caller for errors * @return null or a Jar with the contents for the name */ @Override public Jar getJarFromName(String name, String from) { Jar j = super.getJarFromName(name, from); Glob g = new Glob(name); if (j == null) { for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) { Jar entry = cp.next(); if (entry.getSource() == null) continue; if (g.matcher(entry.getSource() .getName()) .matches()) { return entry; } } } return j; }
/** * Try to get a Jar from a file name/path or a url, or in last resort from * the classpath name part of their files. * * @param name URL or filename relative to the base * @param from Message identifying the caller for errors * @return null or a Jar with the contents for the name */ @Override public Jar getJarFromName(String name, String from) { Jar j = super.getJarFromName(name, from); Glob g = new Glob(name); if (j == null) { for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) { Jar entry = cp.next(); if (entry.getSource() == null) continue; if (g.matcher(entry.getSource() .getName()) .matches()) { return entry; } } } return j; }
/** * Answer the string of the resource that it has in the container. It is * possible that the resource is a classpath entry. In that case an empty * string is returned. * * @param resource The resource to look for * @return A suffix on the classpath or "" if the resource is a class path * entry * @throws Exception */ public String getClasspathEntrySuffix(File resource) throws Exception { for (Jar jar : getClasspath()) { File source = jar.getSource(); if (source != null) { String sourcePath = IO.absolutePath(source); String resourcePath = IO.absolutePath(resource); if (sourcePath.equals(resourcePath)) return ""; // Matches a classpath entry if (resourcePath.startsWith(sourcePath)) { // Make sure that the path name is translated correctly // i.e. on Windows the \ must be translated to / String filePath = resourcePath.substring(sourcePath.length() + 1); return filePath; } } } return null; }
/** * Answer the string of the resource that it has in the container. It is * possible that the resource is a classpath entry. In that case an empty * string is returned. * * @param resource The resource to look for * @return A suffix on the classpath or "" if the resource is a class path * entry * @throws Exception */ public String getClasspathEntrySuffix(File resource) throws Exception { for (Jar jar : getClasspath()) { File source = jar.getSource(); if (source != null) { String sourcePath = IO.absolutePath(source); String resourcePath = IO.absolutePath(resource); if (sourcePath.equals(resourcePath)) return ""; // Matches a classpath entry if (resourcePath.startsWith(sourcePath)) { // Make sure that the path name is translated correctly // i.e. on Windows the \ must be translated to / String filePath = resourcePath.substring(sourcePath.length() + 1); return filePath; } } } return null; }
private void noSuchFile(Jar jar, String clause, Map<String, String> extra, String source, String destinationPath) throws Exception { List<Jar> src = getJarsFromName(source, Constants.INCLUDE_RESOURCE + " " + source); if (!src.isEmpty()) { for (Jar j : src) { String quoted = j.getSource() != null ? j.getSource() .getName() : j.getName(); // Do not touch the manifest so this also // works for signed files. j.setDoNotTouchManifest(); JarResource jarResource = new JarResource(j); String path = destinationPath.replace(source, quoted); logger.debug("copy d={} s={} path={}", jar, j, path); copy(jar, path, jarResource, extra); } } else { Resource lastChance = make.process(source); if (lastChance != null) { String x = extra.get("extra"); if (x != null) lastChance.setExtra(x); copy(jar, destinationPath, lastChance, extra); } else error("Input file does not exist: %s", source).header(source) .context(clause); } }
private void noSuchFile(Jar jar, String clause, Map<String, String> extra, String source, String destinationPath) throws Exception { List<Jar> src = getJarsFromName(source, Constants.INCLUDE_RESOURCE + " " + source); if (!src.isEmpty()) { for (Jar j : src) { String quoted = j.getSource() != null ? j.getSource() .getName() : j.getName(); // Do not touch the manifest so this also // works for signed files. j.setDoNotTouchManifest(); JarResource jarResource = new JarResource(j); String path = destinationPath.replace(source, quoted); logger.debug("copy d={} s={} path={}", jar, j, path); copy(jar, path, jarResource, extra); } } else { Resource lastChance = make.process(source); if (lastChance != null) { String x = extra.get("extra"); if (x != null) lastChance.setExtra(x); copy(jar, destinationPath, lastChance, extra); } else error("Input file does not exist: %s", source).header(source) .context(clause); } }