本文整理汇总了Java中org.uberfire.java.nio.file.Paths类的典型用法代码示例。如果您正苦于以下问题:Java Paths类的具体用法?Java Paths怎么用?Java Paths使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Paths类属于org.uberfire.java.nio.file包,在下文中一共展示了Paths类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTemplateContent
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
@Override
public String getTemplateContent(String url) {
String pluginTemplateContent = getRuntimePluginTemplateContent(url);
if (isAJarPluginTemplate(pluginTemplateContent)) {
return pluginTemplateContent;
}
String realPath = PluginUtils.getRealPath("plugins");
if (realPath == null) {
LOGGER.info("Not fetching template content for " + url + " because getRealPath() is"
+ " returning null. (This app is probably deployed in an unexploded .war)");
return "";
}
final Path template;
if (url.startsWith("/")) {
template = Paths.get(URI.create("file://" + realPath + url));
} else {
template = Paths.get(URI.create("file://" + realPath + "/" + url));
}
if (Files.isRegularFile(template)) {
return new String(Files.readAllBytes(template));
}
return "";
}
示例2: directoryContent
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
private Collection<String> directoryContent(final String directory,
final String glob) {
String realPath = PluginUtils.getRealPath(directory);
if (realPath == null) {
LOGGER.info("Not listing directory content for " + directory + "/" + glob +
" because getRealPath() is returning null. (This app is probably deployed in an unexploded .war)");
return Collections.emptyList();
}
final Collection<String> result = new ArrayList<String>();
final Path pluginsRootPath = Paths.get(URI.create("file://" + realPath));
if (Files.isDirectory(pluginsRootPath)) {
final DirectoryStream<Path> stream = Files.newDirectoryStream(pluginsRootPath,
glob);
for (final Path activeJS : stream) {
result.add(new String(Files.readAllBytes(activeJS)));
}
}
return result;
}
示例3: resolveDependenciesFromMultimodulePrj
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
public static List<Artifact> resolveDependenciesFromMultimodulePrj(List<String> pomsPaths) {
MavenXpp3Reader reader = new MavenXpp3Reader();
List<Artifact> deps = new ArrayList<>();
try {
for (String pomx : pomsPaths) {
Path pom = Paths.get(pomx);
Model model = reader.read(new ByteArrayInputStream(Files.readAllBytes(pom)));
if (model.getDependencyManagement() != null && model.getDependencyManagement().getDependencies() != null) {
createArtifacts(model.getDependencyManagement().getDependencies(),
deps);
}
if (model.getDependencies() != null) {
createArtifacts(model.getDependencies(),
deps);
}
}
} catch (Exception ex) {
logger.error(ex.getMessage());
return Collections.emptyList();
}
return deps;
}
示例4: getClassloaderFromAllDependencies
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
/**
* Execute a maven run to create the classloaders with the dependencies in the Poms, transitive inclueded
*/
public Optional<ClassLoader> getClassloaderFromAllDependencies(String prjPath,
String localRepo) {
AFCompiler compiler = MavenCompilerFactory.getCompiler(Decorator.NONE);
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(prjPath));
StringBuilder sb = new StringBuilder(MavenConfig.MAVEN_DEP_PLUGING_OUTPUT_FILE).append(MavenConfig.CLASSPATH_FILENAME).append(MavenConfig.CLASSPATH_EXT);
CompilationRequest req = new DefaultCompilationRequest(localRepo,
info,
new String[]{MavenConfig.DEPS_BUILD_CLASSPATH, sb.toString()},
new HashMap<>(),
Boolean.FALSE);
CompilationResponse res = compiler.compileSync(req);
if (res.isSuccessful()) {
/** Maven dependency plugin is not able to append the modules classpath using an absolute path in -Dmdep.outputFile,
it override each time and at the end only the last writted is present in the file,
for this reason we use a relative path and then we read each file present in each module to build a unique classpath file
* */
Optional<ClassLoader> urlClassLoader = createClassloaderFromCpFiles(prjPath);
if (urlClassLoader != null) {
return urlClassLoader;
}
}
return Optional.empty();
}
示例5: getTargetModulesURL
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
private List<URL> getTargetModulesURL(List<String> pomsPaths) {
if (pomsPaths != null && pomsPaths.size() > 0) {
List<URL> targetModulesUrls = new ArrayList(pomsPaths.size());
try {
for (String pomPath : pomsPaths) {
Path path = Paths.get(pomPath);
StringBuilder sb = new StringBuilder("file://")
.append(path.getParent().toAbsolutePath().toString())
.append("/target/classes/");
targetModulesUrls.add(new URL(sb.toString()));
}
} catch (MalformedURLException ex) {
logger.error(ex.getMessage());
}
return targetModulesUrls;
} else {
return Collections.emptyList();
}
}
示例6: readAllCpFilesAsUrls
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
private List<URL> readAllCpFilesAsUrls(String prjPath,
String extension) {
List<String> classPathFiles = new ArrayList<>();
searchCPFiles(Paths.get(prjPath),
classPathFiles,
extension);
if (!classPathFiles.isEmpty()) {
List<URL> deps = new ArrayList<>();
for (String file : classPathFiles) {
deps.addAll(readFileAsURL(file));
}
if (!deps.isEmpty()) {
return deps;
}
}
return Collections.emptyList();
}
示例7: getURISFromAllDependencies
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
/**
* Provides a list of URI of all jar used in the project, dependencies plus jar created in the target folder
*/
public Optional<List<URI>> getURISFromAllDependencies(String prjPath) {
List<String> classPathFiles = new ArrayList<>();
searchCPFiles(Paths.get(prjPath),
classPathFiles,
MavenConfig.CLASSPATH_EXT,
JAVA_ARCHIVE_RESOURCE_EXT);
if (!classPathFiles.isEmpty()) {
List<URI> deps = processScannedFiles(classPathFiles);
if (!deps.isEmpty()) {
return Optional.of(deps);
}
}
return Optional.empty();
}
示例8: process
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
@Override
public ProcessedPoms process(final CompilationRequest req) {
Path mainPom = Paths.get(req.getInfo().getPrjPath().toString(),
POM_NAME);
if (!Files.isReadable(mainPom)) {
return new ProcessedPoms(Boolean.FALSE,
Collections.emptyList());
}
PomPlaceHolder placeHolder = editor.readSingle(mainPom);
Boolean isPresent = isPresent(placeHolder); // check if the main pom is already scanned and edited
if (placeHolder.isValid() && !isPresent) {
List<String> pomsList = new ArrayList<>();
MavenUtils.searchPoms(Paths.get(req.getInfo().getPrjPath().toString()),
pomsList);// recursive NIO search in all subfolders
if (pomsList.size() > 0) {
processFoundPoms(pomsList,
req);
}
return new ProcessedPoms(Boolean.TRUE,
pomsList);
} else {
return new ProcessedPoms(Boolean.FALSE,
Collections.emptyList());
}
}
示例9: presenceOfDepInThePrj
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
@Test
public void presenceOfDepInThePrj() throws Exception {
DefaultIncrementalCompilerEnabler enabler = new DefaultIncrementalCompilerEnabler(Compilers.JAVAC);
List<String> pomList = new ArrayList<>();
MavenUtils.searchPoms(Paths.get("src/test/projects/dummy_kie_multimodule_untouched/"),
pomList);
assertTrue(pomList.size() == 3);
List<Artifact> deps = MavenUtils.resolveDependenciesFromMultimodulePrj(pomList);
assertTrue(deps.size() == 1);
Artifact artifact = deps.get(0);
assertTrue(artifact.getArtifactId().equals("kie-api"));
assertTrue(artifact.getGroupId().equals("org.kie"));
assertTrue(artifact.getVersion().equals("6.5.0.Final"));
assertTrue(artifact.getType().equals("jar"));
assertTrue(artifact.toString().equals("org.kie:kie-api:jar:6.5.0.Final"));
}
示例10: getWatchable
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
public Path getWatchable() {
if (watchable == null) {
return null;
}
try {
return Paths.get(watchable);
} catch (Exception e) {
return null;
}
}
示例11: context
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
@Override
public Object context() {
return new WatchContext() {
@Override
public Path getPath() {
return newPath != null ? lookup(newPath) : null;
}
@Override
public Path getOldPath() {
return oldPath != null ? lookup(oldPath) : null;
}
private Path lookup(URI uri) {
Path path = null;
try {
path = Paths.get(uri);
} catch (Exception e) {
LOGGER.error("Error trying to translate to path uri: " + uri);
}
return path;
}
@Override
public String getSessionId() {
return sessionId;
}
@Override
public String getMessage() {
return message;
}
@Override
public String getUser() {
return userName;
}
};
}
示例12: testDependentEnumIndexing
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
@Test
public void testDependentEnumIndexing() throws Exception {
final String carFQN = "com.myteam.repro.Car";
final Path testedPath = Paths.get(getClass().getResource("cars/src/main/resources/com/myteam/repro/cars.enumeration").toURI());
final Set<KProperty<?>> properties = indexer.fillIndexBuilder(testedPath).build();
final ModuleDataModelOracle oracle = indexer.getModuleDataModelOracle(testedPath);
Assertions.assertThat(oracle.getModuleModelFields().keySet()).contains(carFQN);
final AbstractListAssert carFields = Assertions.assertThat(properties).filteredOn("name", "ref:field:" + carFQN);
carFields.filteredOn("value", "price").hasSize(1);
carFields.filteredOn("value", "color").hasSize(1);
final AbstractListAssert javaClasses = Assertions.assertThat(properties).filteredOn("name", "ref:java");
javaClasses.filteredOn("value", carFQN).hasSize(1);
}
示例13: readTmpLog
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
public static List<String> readTmpLog(String logFile) {
Path logPath = Paths.get(logFile);
List<String> log = new ArrayList<>();
if (Files.isReadable(logPath)) {
for (String line : Files.readAllLines(logPath,
Charset.defaultCharset())) {
log.add(line);
}
return log;
}
return Collections.emptyList();
}
示例14: compileSync
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
@Override
public T compileSync(CompilationRequest _req) {
final Path path = _req.getInfo().getPrjPath();
final CompilationRequest req;
Git repo;
if (path.getFileSystem() instanceof JGitFileSystem) {
final JGitFileSystem fs = (JGitFileSystem) path.getFileSystem();
if (!gitMap.containsKey(fs)) {
repo = JGitUtils.tempClone(fs, _req.getRequestUUID());
gitMap.put(fs,
repo);
}
repo = gitMap.get(fs);
JGitUtils.applyBefore(repo);
req = new DefaultCompilationRequest(_req.getMavenRepo(),
new WorkspaceCompilationInfo(Paths.get(repo.getRepository().getDirectory().toPath().getParent().resolve(path.getFileName().toString()).normalize().toUri())),
_req.getOriginalArgs(),
_req.getMap(),
_req.getLogRequested());
} else {
req = _req;
}
return compiler.compileSync(req);
}
示例15: loadDependenciesClassloaderFromProject
import org.uberfire.java.nio.file.Paths; //导入依赖的package包/类
/**
* Load the dependencies from the Poms, transitive included
*/
public Optional<ClassLoader> loadDependenciesClassloaderFromProject(String prjPath,
String localRepo) {
List<String> poms = new ArrayList<>();
MavenUtils.searchPoms(Paths.get(prjPath),
poms);
List<URL> urls = getDependenciesURL(poms,
localRepo);
return buildResult(urls);
}