aQute.bnd.osgi.Jar.getSource()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中aQute.bnd.osgi.Jar.getSource()方法的一些代码示例,展示了Jar.getSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.getSource()方法的具体详情如下:
包路径:aQute.bnd.osgi.Jar
类名称:Jar
方法名:getSource

Jar.getSource介绍

暂无

代码示例

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. protected String getName(Jar jar) throws Exception {
  2. String name = jar.getBsn();
  3. if (name == null) {
  4. name = jar.getName();
  5. if (name.equals("dot") && jar.getSource() != null)
  6. name = jar.getSource()
  7. .getName();
  8. }
  9. String version = jar.getVersion();
  10. if (version == null)
  11. version = "0.0.0";
  12. return name + "-" + version;
  13. }

代码示例来源:origin: org.apache.felix/maven-bundle-plugin

  1. protected static StringBuilder dumpClasspath( List<Jar> classpath, StringBuilder buf )
  2. {
  3. try
  4. {
  5. buf.append("#-----------------------------------------------------------------------" + NL);
  6. buf.append( "-classpath:\\" + NL );
  7. for ( Iterator<Jar> i = classpath.iterator(); i.hasNext(); )
  8. {
  9. File path = i.next().getSource();
  10. if ( path != null )
  11. {
  12. buf.append( ' ' + path.toString() + ( i.hasNext() ? ",\\" : "" ) + NL );
  13. }
  14. }
  15. buf.append( "#-----------------------------------------------------------------------" + NL );
  16. }
  17. catch ( Throwable e )
  18. {
  19. // ignore...
  20. }
  21. return buf;
  22. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. protected String getName(Jar jar) throws Exception {
  2. String name = jar.getBsn();
  3. if (name == null) {
  4. name = jar.getName();
  5. if (name.equals("dot") && jar.getSource() != null)
  6. name = jar.getSource()
  7. .getName();
  8. }
  9. String version = jar.getVersion();
  10. if (version == null)
  11. version = "0.0.0";
  12. return name + "-" + version;
  13. }

代码示例来源:origin: biz.aQute.bnd/bnd

  1. /**
  2. * Try to get a Jar from a file name/path or a url, or in last resort from
  3. * the classpath name part of their files.
  4. *
  5. * @param name
  6. * URL or filename relative to the base
  7. * @param from
  8. * Message identifying the caller for errors
  9. * @return null or a Jar with the contents for the name
  10. */
  11. public Jar getJarFromName(String name, String from) {
  12. Jar j = super.getJarFromName(name, from);
  13. if (j == null) {
  14. for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) {
  15. Jar entry = cp.next();
  16. if (entry.getSource() != null && entry.getSource().getName().equals(name)) {
  17. return entry;
  18. }
  19. }
  20. }
  21. return j;
  22. }

代码示例来源:origin: biz.aQute.bnd/bndlib

  1. /**
  2. * Try to get a Jar from a file name/path or a url, or in last resort from
  3. * the classpath name part of their files.
  4. *
  5. * @param name
  6. * URL or filename relative to the base
  7. * @param from
  8. * Message identifying the caller for errors
  9. * @return null or a Jar with the contents for the name
  10. */
  11. public Jar getJarFromName(String name, String from) {
  12. Jar j = super.getJarFromName(name, from);
  13. if (j == null) {
  14. for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) {
  15. Jar entry = cp.next();
  16. if (entry.getSource() != null && entry.getSource().getName().equals(name)) {
  17. return entry;
  18. }
  19. }
  20. }
  21. return j;
  22. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. public List<Jar> getJarsFromName(String name, String from) {
  2. Jar j = super.getJarFromName(name, from);
  3. if (j != null)
  4. return Collections.singletonList(j);
  5. Glob g = new Glob(name);
  6. List<Jar> result = new ArrayList<>();
  7. for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) {
  8. Jar entry = cp.next();
  9. if (entry.getSource() == null)
  10. continue;
  11. if (g.matcher(entry.getSource()
  12. .getName())
  13. .matches()) {
  14. result.add(entry);
  15. }
  16. }
  17. return result;
  18. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. public List<Jar> getJarsFromName(String name, String from) {
  2. Jar j = super.getJarFromName(name, from);
  3. if (j != null)
  4. return Collections.singletonList(j);
  5. Glob g = new Glob(name);
  6. List<Jar> result = new ArrayList<>();
  7. for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) {
  8. Jar entry = cp.next();
  9. if (entry.getSource() == null)
  10. continue;
  11. if (g.matcher(entry.getSource()
  12. .getName())
  13. .matches()) {
  14. result.add(entry);
  15. }
  16. }
  17. return result;
  18. }

代码示例来源:origin: biz.aQute/bndlib

  1. /**
  2. * Answer the string of the resource that it has in the container. It is
  3. * possible that the resource is a classpath entry. In that case an empty
  4. * string is returned.
  5. *
  6. * @param resource
  7. * The resource to look for
  8. * @return A suffix on the classpath or "" if the resource is a class path
  9. * entry
  10. * @throws Exception
  11. */
  12. public String getClasspathEntrySuffix(File resource) throws Exception {
  13. for (Jar jar : getClasspath()) {
  14. File source = jar.getSource();
  15. if (source != null) {
  16. source = source.getCanonicalFile();
  17. String sourcePath = source.getAbsolutePath();
  18. String resourcePath = resource.getAbsolutePath();
  19. if (sourcePath.equals(resourcePath))
  20. return ""; // Matches a classpath entry
  21. if (resourcePath.startsWith(sourcePath)) {
  22. // Make sure that the path name is translated correctly
  23. // i.e. on Windows the \ must be translated to /
  24. String filePath = resourcePath.substring(sourcePath.length() + 1);
  25. return filePath.replace(File.separatorChar, '/');
  26. }
  27. }
  28. }
  29. return null;
  30. }

代码示例来源:origin: biz.aQute.bnd/bnd

  1. /**
  2. * Answer the string of the resource that it has in the container. It is
  3. * possible that the resource is a classpath entry. In that case an empty
  4. * string is returned.
  5. *
  6. * @param resource
  7. * The resource to look for
  8. * @return A suffix on the classpath or "" if the resource is a class path
  9. * entry
  10. * @throws Exception
  11. */
  12. public String getClasspathEntrySuffix(File resource) throws Exception {
  13. for (Jar jar : getClasspath()) {
  14. File source = jar.getSource();
  15. if (source != null) {
  16. source = source.getCanonicalFile();
  17. String sourcePath = source.getAbsolutePath();
  18. String resourcePath = resource.getAbsolutePath();
  19. if (sourcePath.equals(resourcePath))
  20. return ""; // Matches a classpath entry
  21. if (resourcePath.startsWith(sourcePath)) {
  22. // Make sure that the path name is translated correctly
  23. // i.e. on Windows the \ must be translated to /
  24. String filePath = resourcePath.substring(sourcePath.length() + 1);
  25. return filePath.replace(File.separatorChar, '/');
  26. }
  27. }
  28. }
  29. return null;
  30. }

代码示例来源:origin: biz.aQute.bnd/bndlib

  1. /**
  2. * Answer the string of the resource that it has in the container. It is
  3. * possible that the resource is a classpath entry. In that case an empty
  4. * string is returned.
  5. *
  6. * @param resource
  7. * The resource to look for
  8. * @return A suffix on the classpath or "" if the resource is a class path
  9. * entry
  10. * @throws Exception
  11. */
  12. public String getClasspathEntrySuffix(File resource) throws Exception {
  13. for (Jar jar : getClasspath()) {
  14. File source = jar.getSource();
  15. if (source != null) {
  16. source = source.getCanonicalFile();
  17. String sourcePath = source.getAbsolutePath();
  18. String resourcePath = resource.getAbsolutePath();
  19. if (sourcePath.equals(resourcePath))
  20. return ""; // Matches a classpath entry
  21. if (resourcePath.startsWith(sourcePath)) {
  22. // Make sure that the path name is translated correctly
  23. // i.e. on Windows the \ must be translated to /
  24. String filePath = resourcePath.substring(sourcePath.length() + 1);
  25. return filePath.replace(File.separatorChar, '/');
  26. }
  27. }
  28. }
  29. return null;
  30. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. out.println("Classpath used");
  2. for (Jar jar : getClasspath()) {
  3. out.printf("File : %s%n", jar.getSource());
  4. out.printf("File abs path : %s%n", jar.getSource()
  5. .getAbsolutePath());
  6. out.printf("Name : %s%n", jar.getName());

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. /**
  2. * Try to get a Jar from a file name/path or a url, or in last resort from
  3. * the classpath name part of their files.
  4. *
  5. * @param name URL or filename relative to the base
  6. * @param from Message identifying the caller for errors
  7. * @return null or a Jar with the contents for the name
  8. */
  9. @Override
  10. public Jar getJarFromName(String name, String from) {
  11. Jar j = super.getJarFromName(name, from);
  12. Glob g = new Glob(name);
  13. if (j == null) {
  14. for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) {
  15. Jar entry = cp.next();
  16. if (entry.getSource() == null)
  17. continue;
  18. if (g.matcher(entry.getSource()
  19. .getName())
  20. .matches()) {
  21. return entry;
  22. }
  23. }
  24. }
  25. return j;
  26. }

代码示例来源:origin: biz.aQute/bndlib

  1. out.println("Classpath used");
  2. for (Jar jar : getClasspath()) {
  3. out.printf("File : %s%n", jar.getSource());
  4. out.printf("File abs path : %s%n", jar.getSource().getAbsolutePath());
  5. out.printf("Name : %s%n", jar.getName());
  6. Map<String,Map<String,Resource>> dirs = jar.getDirectories();

代码示例来源:origin: biz.aQute.bnd/bndlib

  1. out.println("Classpath used");
  2. for (Jar jar : getClasspath()) {
  3. out.printf("File : %s%n", jar.getSource());
  4. out.printf("File abs path : %s%n", jar.getSource().getAbsolutePath());
  5. out.printf("Name : %s%n", jar.getName());
  6. Map<String,Map<String,Resource>> dirs = jar.getDirectories();

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. /**
  2. * Try to get a Jar from a file name/path or a url, or in last resort from
  3. * the classpath name part of their files.
  4. *
  5. * @param name URL or filename relative to the base
  6. * @param from Message identifying the caller for errors
  7. * @return null or a Jar with the contents for the name
  8. */
  9. @Override
  10. public Jar getJarFromName(String name, String from) {
  11. Jar j = super.getJarFromName(name, from);
  12. Glob g = new Glob(name);
  13. if (j == null) {
  14. for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext();) {
  15. Jar entry = cp.next();
  16. if (entry.getSource() == null)
  17. continue;
  18. if (g.matcher(entry.getSource()
  19. .getName())
  20. .matches()) {
  21. return entry;
  22. }
  23. }
  24. }
  25. return j;
  26. }

代码示例来源:origin: biz.aQute.bnd/bnd

  1. out.println("Classpath used");
  2. for (Jar jar : getClasspath()) {
  3. out.printf("File : %s%n", jar.getSource());
  4. out.printf("File abs path : %s%n", jar.getSource().getAbsolutePath());
  5. out.printf("Name : %s%n", jar.getName());
  6. Map<String,Map<String,Resource>> dirs = jar.getDirectories();

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. /**
  2. * Answer the string of the resource that it has in the container. It is
  3. * possible that the resource is a classpath entry. In that case an empty
  4. * string is returned.
  5. *
  6. * @param resource The resource to look for
  7. * @return A suffix on the classpath or "" if the resource is a class path
  8. * entry
  9. * @throws Exception
  10. */
  11. public String getClasspathEntrySuffix(File resource) throws Exception {
  12. for (Jar jar : getClasspath()) {
  13. File source = jar.getSource();
  14. if (source != null) {
  15. String sourcePath = IO.absolutePath(source);
  16. String resourcePath = IO.absolutePath(resource);
  17. if (sourcePath.equals(resourcePath))
  18. return ""; // Matches a classpath entry
  19. if (resourcePath.startsWith(sourcePath)) {
  20. // Make sure that the path name is translated correctly
  21. // i.e. on Windows the \ must be translated to /
  22. String filePath = resourcePath.substring(sourcePath.length() + 1);
  23. return filePath;
  24. }
  25. }
  26. }
  27. return null;
  28. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. /**
  2. * Answer the string of the resource that it has in the container. It is
  3. * possible that the resource is a classpath entry. In that case an empty
  4. * string is returned.
  5. *
  6. * @param resource The resource to look for
  7. * @return A suffix on the classpath or "" if the resource is a class path
  8. * entry
  9. * @throws Exception
  10. */
  11. public String getClasspathEntrySuffix(File resource) throws Exception {
  12. for (Jar jar : getClasspath()) {
  13. File source = jar.getSource();
  14. if (source != null) {
  15. String sourcePath = IO.absolutePath(source);
  16. String resourcePath = IO.absolutePath(resource);
  17. if (sourcePath.equals(resourcePath))
  18. return ""; // Matches a classpath entry
  19. if (resourcePath.startsWith(sourcePath)) {
  20. // Make sure that the path name is translated correctly
  21. // i.e. on Windows the \ must be translated to /
  22. String filePath = resourcePath.substring(sourcePath.length() + 1);
  23. return filePath;
  24. }
  25. }
  26. }
  27. return null;
  28. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. private void noSuchFile(Jar jar, String clause, Map<String, String> extra, String source, String destinationPath)
  2. throws Exception {
  3. List<Jar> src = getJarsFromName(source, Constants.INCLUDE_RESOURCE + " " + source);
  4. if (!src.isEmpty()) {
  5. for (Jar j : src) {
  6. String quoted = j.getSource() != null ? j.getSource()
  7. .getName() : j.getName();
  8. // Do not touch the manifest so this also
  9. // works for signed files.
  10. j.setDoNotTouchManifest();
  11. JarResource jarResource = new JarResource(j);
  12. String path = destinationPath.replace(source, quoted);
  13. logger.debug("copy d={} s={} path={}", jar, j, path);
  14. copy(jar, path, jarResource, extra);
  15. }
  16. } else {
  17. Resource lastChance = make.process(source);
  18. if (lastChance != null) {
  19. String x = extra.get("extra");
  20. if (x != null)
  21. lastChance.setExtra(x);
  22. copy(jar, destinationPath, lastChance, extra);
  23. } else
  24. error("Input file does not exist: %s", source).header(source)
  25. .context(clause);
  26. }
  27. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. private void noSuchFile(Jar jar, String clause, Map<String, String> extra, String source, String destinationPath)
  2. throws Exception {
  3. List<Jar> src = getJarsFromName(source, Constants.INCLUDE_RESOURCE + " " + source);
  4. if (!src.isEmpty()) {
  5. for (Jar j : src) {
  6. String quoted = j.getSource() != null ? j.getSource()
  7. .getName() : j.getName();
  8. // Do not touch the manifest so this also
  9. // works for signed files.
  10. j.setDoNotTouchManifest();
  11. JarResource jarResource = new JarResource(j);
  12. String path = destinationPath.replace(source, quoted);
  13. logger.debug("copy d={} s={} path={}", jar, j, path);
  14. copy(jar, path, jarResource, extra);
  15. }
  16. } else {
  17. Resource lastChance = make.process(source);
  18. if (lastChance != null) {
  19. String x = extra.get("extra");
  20. if (x != null)
  21. lastChance.setExtra(x);
  22. copy(jar, destinationPath, lastChance, extra);
  23. } else
  24. error("Input file does not exist: %s", source).header(source)
  25. .context(clause);
  26. }
  27. }

相关文章