use of io.quarkus.paths.MultiRootPathTree in project quarkus by quarkusio.
the class SnapshotTesting method getSnapshotsBaseTree.
public static PathTree getSnapshotsBaseTree() {
if (snapshotsBaseRoot != null) {
return snapshotsBaseRoot;
}
PathTree srcTree = null;
if (Files.isDirectory(SNAPSHOTS_DIR)) {
srcTree = PathTree.ofDirectoryOrArchive(SNAPSHOTS_DIR.getParent());
} else if (shouldUpdateSnapshot(SNAPSHOTS_DIR_NAME)) {
try {
Files.createDirectories(SNAPSHOTS_DIR);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
srcTree = PathTree.ofDirectoryOrArchive(SNAPSHOTS_DIR.getParent());
}
final URL url = Thread.currentThread().getContextClassLoader().getResource(SNAPSHOTS_DIR_NAME);
if (url == null) {
if (srcTree == null) {
Assertions.fail("Failed to locate " + SNAPSHOTS_DIR_NAME + " directory on the classpath and " + SNAPSHOTS_DIR.toAbsolutePath() + " directory does not exist (use -Dsnap to create it automatically)");
}
return snapshotsBaseRoot = srcTree;
} else if ("file".equals(url.getProtocol())) {
final Path p;
try {
p = Path.of(url.toURI());
} catch (URISyntaxException e) {
throw new IllegalStateException("Failed to translate " + url + " to path", e);
}
return snapshotsBaseRoot = new MultiRootPathTree(PathTree.ofDirectoryOrArchive(p.getParent()), srcTree);
} else if ("jar".equals(url.getProtocol())) {
final String jarUrlStr = url.toExternalForm();
final String fileUrlStr = jarUrlStr.substring("jar:".length(), jarUrlStr.length() - ("!/" + SNAPSHOTS_DIR_NAME).length());
final Path p = Path.of(URI.create(fileUrlStr));
return snapshotsBaseRoot = new MultiRootPathTree(PathTree.ofDirectoryOrArchive(p), srcTree);
} else {
throw new IllegalStateException("Unexpected URL protocol in " + url);
}
}
use of io.quarkus.paths.MultiRootPathTree in project quarkus by quarkusio.
the class ApplicationArchiveBuildStep method build.
@BuildStep
ApplicationArchivesBuildItem build(QuarkusBuildCloseablesBuildItem buildCloseables, ArchiveRootBuildItem root, ApplicationIndexBuildItem appindex, List<AdditionalApplicationArchiveMarkerBuildItem> appMarkers, List<AdditionalApplicationArchiveBuildItem> additionalApplicationArchiveBuildItem, List<IndexDependencyBuildItem> indexDependencyBuildItems, LiveReloadBuildItem liveReloadContext, CurateOutcomeBuildItem curateOutcomeBuildItem, ClassLoadingConfig classLoadingConfig) throws IOException {
IndexCache indexCache = liveReloadContext.getContextObject(IndexCache.class);
if (indexCache == null) {
indexCache = new IndexCache();
liveReloadContext.setContextObject(IndexCache.class, indexCache);
}
Map<ArtifactKey, Set<String>> removedResources = new HashMap<>();
for (Map.Entry<String, Set<String>> entry : classLoadingConfig.removedResources.entrySet()) {
removedResources.put(new GACT(entry.getKey().split(":")), entry.getValue());
}
List<ApplicationArchive> applicationArchives = scanForOtherIndexes(buildCloseables, appMarkers, root, additionalApplicationArchiveBuildItem, indexDependencyBuildItems, indexCache, curateOutcomeBuildItem, removedResources);
final OpenPathTree tree;
if (root.getRootDirectories().size() == 1) {
tree = new DirectoryPathTree(root.getRootDirectories().iterator().next());
} else {
final PathTree[] trees = new PathTree[root.getRootDirectories().size()];
int i = 0;
for (Path p : root.getRootDirectories()) {
trees[i++] = new DirectoryPathTree(p);
}
tree = new MultiRootPathTree(trees);
}
return new ApplicationArchivesBuildItem(new ApplicationArchiveImpl(appindex.getIndex(), tree, curateOutcomeBuildItem.getApplicationModel().getAppArtifact().getKey()), applicationArchives);
}
use of io.quarkus.paths.MultiRootPathTree in project quarkus by quarkusio.
the class ArtifactSources method getOutputTree.
default PathTree getOutputTree() {
final Collection<SourceDir> sourceDirs = getSourceDirs();
final Collection<SourceDir> resourceDirs = getResourceDirs();
final List<PathTree> trees = new ArrayList<>(sourceDirs.size() + resourceDirs.size());
for (SourceDir src : sourceDirs) {
final PathTree outputTree = src.getOutputTree();
if (outputTree != null && !outputTree.isEmpty() && !trees.contains(outputTree)) {
trees.add(outputTree);
}
}
for (SourceDir src : resourceDirs) {
final PathTree outputTree = src.getOutputTree();
if (outputTree != null && !outputTree.isEmpty() && !trees.contains(outputTree)) {
trees.add(outputTree);
}
}
if (trees.isEmpty()) {
return EmptyPathTree.getInstance();
}
if (trees.size() == 1) {
return trees.get(0);
}
return new MultiRootPathTree(trees.toArray(new PathTree[0]));
}
use of io.quarkus.paths.MultiRootPathTree in project quarkus by quarkusio.
the class ResolvedDependency method getContentTree.
default PathTree getContentTree() {
final WorkspaceModule module = getWorkspaceModule();
final PathTree workspaceTree = module == null ? EmptyPathTree.getInstance() : module.getContentTree(getClassifier());
if (!workspaceTree.isEmpty()) {
return workspaceTree;
}
final PathCollection paths = getResolvedPaths();
if (paths == null || paths.isEmpty()) {
return EmptyPathTree.getInstance();
}
if (paths.isSinglePath()) {
final Path p = paths.getSinglePath();
return PathTree.ofDirectoryOrArchive(p);
}
final PathTree[] trees = new PathTree[paths.size()];
int i = 0;
for (Path p : paths) {
trees[i++] = PathTree.ofDirectoryOrArchive(p);
}
return new MultiRootPathTree(trees);
}
Aggregations