本文整理了Java中aQute.bnd.osgi.Jar.getSource()
方法的一些代码示例,展示了Jar.getSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.getSource()
方法的具体详情如下:
包路径:aQute.bnd.osgi.Jar
类名称:Jar
方法名:getSource
暂无
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
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;
}
代码示例来源:origin: org.apache.felix/maven-bundle-plugin
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;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
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;
}
代码示例来源:origin: biz.aQute.bnd/bnd
/**
* 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;
}
代码示例来源:origin: biz.aQute.bnd/bndlib
/**
* 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;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
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;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
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;
}
代码示例来源:origin: biz.aQute/bndlib
/**
* 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;
}
代码示例来源:origin: biz.aQute.bnd/bnd
/**
* 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;
}
代码示例来源:origin: biz.aQute.bnd/bndlib
/**
* 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;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
out.println("Classpath used");
for (Jar jar : getClasspath()) {
out.printf("File : %s%n", jar.getSource());
out.printf("File abs path : %s%n", jar.getSource()
.getAbsolutePath());
out.printf("Name : %s%n", jar.getName());
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
/**
* 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;
}
代码示例来源:origin: biz.aQute/bndlib
out.println("Classpath used");
for (Jar jar : getClasspath()) {
out.printf("File : %s%n", jar.getSource());
out.printf("File abs path : %s%n", jar.getSource().getAbsolutePath());
out.printf("Name : %s%n", jar.getName());
Map<String,Map<String,Resource>> dirs = jar.getDirectories();
代码示例来源:origin: biz.aQute.bnd/bndlib
out.println("Classpath used");
for (Jar jar : getClasspath()) {
out.printf("File : %s%n", jar.getSource());
out.printf("File abs path : %s%n", jar.getSource().getAbsolutePath());
out.printf("Name : %s%n", jar.getName());
Map<String,Map<String,Resource>> dirs = jar.getDirectories();
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
/**
* 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;
}
代码示例来源:origin: biz.aQute.bnd/bnd
out.println("Classpath used");
for (Jar jar : getClasspath()) {
out.printf("File : %s%n", jar.getSource());
out.printf("File abs path : %s%n", jar.getSource().getAbsolutePath());
out.printf("Name : %s%n", jar.getName());
Map<String,Map<String,Resource>> dirs = jar.getDirectories();
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
/**
* 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;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
/**
* 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;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
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);
}
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!