本文整理了Java中aQute.bnd.osgi.Builder.getFile()
方法的一些代码示例,展示了Builder.getFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Builder.getFile()
方法的具体详情如下:
包路径:aQute.bnd.osgi.Builder
类名称:Builder
方法名:getFile
暂无
代码示例来源:origin: biz.aQute/bndlib
/**
* Extra the paths for the directories and files that are used in the
* Include-Resource header.
*
* @return
*/
private Collection<String> getIncludedResourcePrefixes() {
List<String> prefixes = new ArrayList<String>();
Parameters includeResource = getIncludeResource();
for (Entry<String,Attrs> p : includeResource.entrySet()) {
if (p.getValue().containsKey("literal"))
continue;
Matcher m = IR_PATTERN.matcher(p.getKey());
if (m.matches()) {
File f = getFile(m.group(1));
prefixes.add(f.getAbsolutePath());
}
}
return prefixes;
}
代码示例来源:origin: biz.aQute.bnd/bndlib
/**
* Extra the paths for the directories and files that are used in the
* Include-Resource header.
*
* @return
*/
private Collection<String> getIncludedResourcePrefixes() {
List<String> prefixes = new ArrayList<String>();
Parameters includeResource = getIncludeResource();
for (Entry<String,Attrs> p : includeResource.entrySet()) {
if (p.getValue().containsKey("literal"))
continue;
Matcher m = IR_PATTERN.matcher(p.getKey());
if (m.matches()) {
File f = getFile(m.group(1));
prefixes.add(f.getAbsolutePath());
}
}
return prefixes;
}
代码示例来源:origin: biz.aQute/bndlib
public Resource make(Builder builder, String destination, Map<String,String> argumentsOnMake) throws Exception {
String type = argumentsOnMake.get("type");
if (!type.equals("copy"))
return null;
String from = argumentsOnMake.get("from");
if (from == null) {
String content = argumentsOnMake.get("content");
if (content == null)
throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
return new EmbeddedResource(content.getBytes("UTF-8"), 0);
}
File f = builder.getFile(from);
if (f.isFile())
return new FileResource(f);
try {
URL url = new URL(from);
return new URLResource(url);
}
catch (MalformedURLException mfue) {
// We ignore this
}
throw new IllegalArgumentException("Copy source does not exist " + from + " for destination "
+ destination);
}
代码示例来源:origin: biz.aQute.bnd/bnd
/**
* Extra the paths for the directories and files that are used in the
* Include-Resource header.
*
* @return
*/
private Collection<String> getIncludedResourcePrefixes() {
List<String> prefixes = new ArrayList<String>();
Parameters includeResource = getIncludeResource();
for (Entry<String,Attrs> p : includeResource.entrySet()) {
if (p.getValue().containsKey("literal"))
continue;
Matcher m = IR_PATTERN.matcher(p.getKey());
if (m.matches()) {
File f = getFile(m.group(1));
prefixes.add(f.getAbsolutePath());
}
}
return prefixes;
}
代码示例来源:origin: biz.aQute.bnd/bndlib
public Resource make(Builder builder, String destination, Map<String,String> argumentsOnMake) throws Exception {
String type = argumentsOnMake.get("type");
if (!type.equals("copy"))
return null;
String from = argumentsOnMake.get("from");
if (from == null) {
String content = argumentsOnMake.get("content");
if (content == null)
throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
return new EmbeddedResource(content.getBytes("UTF-8"), 0);
}
File f = builder.getFile(from);
if (f.isFile())
return new FileResource(f);
try {
URL url = new URL(from);
return new URLResource(url);
}
catch (MalformedURLException mfue) {
// We ignore this
}
throw new IllegalArgumentException("Copy source does not exist " + from + " for destination "
+ destination);
}
代码示例来源:origin: biz.aQute.bnd/bnd
public Resource make(Builder builder, String destination, Map<String,String> argumentsOnMake) throws Exception {
String type = argumentsOnMake.get("type");
if (!type.equals("copy"))
return null;
String from = argumentsOnMake.get("from");
if (from == null) {
String content = argumentsOnMake.get("content");
if (content == null)
throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
return new EmbeddedResource(content.getBytes("UTF-8"), 0);
}
File f = builder.getFile(from);
if (f.isFile())
return new FileResource(f);
try {
URL url = new URL(from);
return new URLResource(url);
}
catch (MalformedURLException mfue) {
// We ignore this
}
throw new IllegalArgumentException("Copy source does not exist " + from + " for destination "
+ destination);
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
@Override
public Resource make(Builder builder, String destination, Map<String, String> argumentsOnMake) throws Exception {
String type = argumentsOnMake.get("type");
if (!type.equals("copy"))
return null;
String from = argumentsOnMake.get("from");
if (from == null) {
String content = argumentsOnMake.get("content");
if (content == null)
throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
return new EmbeddedResource(content, 0L);
}
File f = builder.getFile(from);
if (f.isFile())
return new FileResource(f);
try {
URL url = new URL(from);
return Resource.fromURL(url, builder.getPlugin(HttpClient.class));
} catch (MalformedURLException mfue) {
// We ignore this
}
throw new IllegalArgumentException("Copy source does not exist " + from + " for destination " + destination);
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
@Override
public Resource make(Builder builder, String destination, Map<String, String> argumentsOnMake) throws Exception {
String type = argumentsOnMake.get("type");
if (!type.equals("copy"))
return null;
String from = argumentsOnMake.get("from");
if (from == null) {
String content = argumentsOnMake.get("content");
if (content == null)
throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
return new EmbeddedResource(content, 0L);
}
File f = builder.getFile(from);
if (f.isFile())
return new FileResource(f);
try {
URL url = new URL(from);
return Resource.fromURL(url, builder.getPlugin(HttpClient.class));
} catch (MalformedURLException mfue) {
// We ignore this
}
throw new IllegalArgumentException("Copy source does not exist " + from + " for destination " + destination);
}
代码示例来源:origin: biz.aQute/bndlib
/**
* Get the manifest and write it out separately if -savemanifest is set
*
* @param dot
*/
private void doSaveManifest(Jar dot) throws Exception {
String output = getProperty(SAVEMANIFEST);
if (output == null)
return;
File f = getFile(output);
if (f.isDirectory()) {
f = new File(f, "MANIFEST.MF");
}
f.delete();
File fp = f.getParentFile();
if (!fp.exists() && !fp.mkdirs()) {
throw new IOException("Could not create directory " + fp);
}
OutputStream out = new FileOutputStream(f);
try {
Jar.writeManifest(dot.getManifest(), out);
}
finally {
out.close();
}
changedFile(f);
}
代码示例来源:origin: biz.aQute.bnd/bndlib
/**
* Get the manifest and write it out separately if -savemanifest is set
*
* @param dot
*/
private void doSaveManifest(Jar dot) throws Exception {
String output = getProperty(SAVEMANIFEST);
if (output == null)
return;
File f = getFile(output);
if (f.isDirectory()) {
f = new File(f, "MANIFEST.MF");
}
f.delete();
File fp = f.getParentFile();
if (!fp.exists() && !fp.mkdirs()) {
throw new IOException("Could not create directory " + fp);
}
OutputStream out = new FileOutputStream(f);
try {
Jar.writeManifest(dot.getManifest(), out);
}
finally {
out.close();
}
changedFile(f);
}
代码示例来源:origin: biz.aQute/bndlib
public Collection<File> getSourcePath() {
if (firstUse) {
firstUse = false;
String sp = getProperty(SOURCEPATH);
if (sp != null) {
Parameters map = parseHeader(sp);
for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
String file = i.next();
if (!isDuplicate(file)) {
File f = getFile(file);
if (!f.isDirectory()) {
error("Adding a sourcepath that is not a directory: " + f);
} else {
sourcePath.add(f);
}
}
}
}
}
return sourcePath;
}
代码示例来源:origin: biz.aQute.bnd/bnd
public Collection<File> getSourcePath() {
if (firstUse) {
firstUse = false;
String sp = getProperty(SOURCEPATH);
if (sp != null) {
Parameters map = parseHeader(sp);
for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
String file = i.next();
if (!isDuplicate(file)) {
File f = getFile(file);
if (!f.isDirectory()) {
error("Adding a sourcepath that is not a directory: " + f);
} else {
sourcePath.add(f);
}
}
}
}
}
return sourcePath;
}
代码示例来源:origin: biz.aQute.bnd/bndlib
public Collection<File> getSourcePath() {
if (firstUse) {
firstUse = false;
String sp = getProperty(SOURCEPATH);
if (sp != null) {
Parameters map = parseHeader(sp);
for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
String file = i.next();
if (!isDuplicate(file)) {
File f = getFile(file);
if (!f.isDirectory()) {
error("Adding a sourcepath that is not a directory: " + f);
} else {
sourcePath.add(f);
}
}
}
}
}
return sourcePath;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
public Collection<File> getSourcePath() {
if (firstUse) {
firstUse = false;
String sp = mergeProperties(SOURCEPATH);
if (sp != null) {
Parameters map = parseHeader(sp);
for (Iterator<String> i = map.keySet()
.iterator(); i.hasNext();) {
String file = i.next();
if (!isDuplicate(file)) {
File f = getFile(file);
if (!f.isDirectory()) {
error("Adding a sourcepath that is not a directory: %s", f).header(SOURCEPATH)
.context(file);
} else {
sourcePath.add(f);
}
}
}
}
}
return sourcePath;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
public Collection<File> getSourcePath() {
if (firstUse) {
firstUse = false;
String sp = mergeProperties(SOURCEPATH);
if (sp != null) {
Parameters map = parseHeader(sp);
for (Iterator<String> i = map.keySet()
.iterator(); i.hasNext();) {
String file = i.next();
if (!isDuplicate(file)) {
File f = getFile(file);
if (!f.isDirectory()) {
error("Adding a sourcepath that is not a directory: %s", f).header(SOURCEPATH)
.context(file);
} else {
sourcePath.add(f);
}
}
}
}
}
return sourcePath;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
/**
* Turn this normal bundle in a web and add any resources.
*
* @throws Exception
*/
private Jar doWab(Jar dot) throws Exception {
String wab = getProperty(WAB);
String wablib = getProperty(WABLIB);
if (wab == null && wablib == null)
return dot;
logger.debug("wab {} {}", wab, wablib);
setBundleClasspath(append("WEB-INF/classes", getProperty(BUNDLE_CLASSPATH)));
Set<String> paths = new HashSet<>(dot.getResources()
.keySet());
for (String path : paths) {
if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) {
logger.debug("wab: moving: {}", path);
dot.rename(path, "WEB-INF/classes/" + path);
}
}
Parameters clauses = parseHeader(getProperty(WABLIB));
for (Map.Entry<String, Attrs> entry : clauses.entrySet()) {
File f = getFile(entry.getKey());
addWabLib(dot, f, entry.getKey(), entry.getValue());
}
doIncludeResource(dot, wab);
return dot;
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
/**
* Get the manifest and write it out separately if -savemanifest is set
*
* @param dot
*/
private void doSaveManifest(Jar dot) throws Exception {
String output = getProperty(SAVEMANIFEST);
if (output == null)
return;
File f = getFile(output);
if (f.isDirectory()) {
f = new File(f, "MANIFEST.MF");
}
if (!f.exists() || f.lastModified() < dot.lastModified()) {
IO.delete(f);
File fp = f.getParentFile();
IO.mkdirs(fp);
try (OutputStream out = IO.outputStream(f)) {
Jar.writeManifest(dot.getManifest(), out);
}
changedFile(f);
}
}
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd
/**
* Get the manifest and write it out separately if -savemanifest is set
*
* @param dot
*/
private void doSaveManifest(Jar dot) throws Exception {
String output = getProperty(SAVEMANIFEST);
if (output == null)
return;
File f = getFile(output);
if (f.isDirectory()) {
f = new File(f, "MANIFEST.MF");
}
if (!f.exists() || f.lastModified() < dot.lastModified()) {
IO.delete(f);
File fp = f.getParentFile();
IO.mkdirs(fp);
try (OutputStream out = IO.outputStream(f)) {
Jar.writeManifest(dot.getManifest(), out);
}
changedFile(f);
}
}
代码示例来源:origin: biz.aQute.bnd/bndlib
Collection<String> parts = split(cp, ",");
for (String part : parts) {
File sub = getFile(f.getParentFile(), part);
if (!sub.exists() || !sub.getParentFile().equals(f.getParentFile())) {
warning("Invalid Class-Path entry %s in %s, must exist and must reside in same directory", sub,
代码示例来源:origin: biz.aQute/bndlib
/**
* Turn this normal bundle in a web and add any resources.
*
* @throws Exception
*/
private Jar doWab(Jar dot) throws Exception {
String wab = getProperty(WAB);
String wablib = getProperty(WABLIB);
if (wab == null && wablib == null)
return dot;
trace("wab %s %s", wab, wablib);
setBundleClasspath(append("WEB-INF/classes", getProperty(BUNDLE_CLASSPATH)));
Set<String> paths = new HashSet<String>(dot.getResources().keySet());
for (String path : paths) {
if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) {
trace("wab: moving: %s", path);
dot.rename(path, "WEB-INF/classes/" + path);
}
}
Parameters clauses = parseHeader(getProperty(WABLIB));
for (String key : clauses.keySet()) {
File f = getFile(key);
addWabLib(dot, f);
}
doIncludeResource(dot, wab);
return dot;
}
内容来源于网络,如有侵权,请联系作者删除!