use of io.quarkus.maven.dependency.Dependency in project kogito-runtimes by kiegroup.
the class KogitoQuarkusResourceUtils method kogitoBuildContext.
public static KogitoBuildContext kogitoBuildContext(Path outputTarget, Iterable<Path> paths, IndexView index, Dependency appArtifact) {
// scan and parse paths
AppPaths.BuildTool buildTool;
if (System.getProperty("org.gradle.appname") == null) {
buildTool = AppPaths.BuildTool.MAVEN;
} else {
buildTool = AppPaths.BuildTool.GRADLE;
}
AppPaths appPaths = AppPaths.fromQuarkus(outputTarget, paths, buildTool);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
KogitoBuildContext context = QuarkusKogitoBuildContext.builder().withApplicationPropertyProvider(new KogitoQuarkusApplicationPropertiesProvider()).withClassLoader(classLoader).withClassAvailabilityResolver(className -> classAvailabilityResolver(classLoader, index, className)).withAppPaths(appPaths).withGAV(new KogitoGAV(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getVersion())).build();
if (!context.hasClassAvailable(QuarkusKogitoBuildContext.QUARKUS_REST)) {
LOGGER.info("Disabling REST generation because class '" + QuarkusKogitoBuildContext.QUARKUS_REST + "' is not available");
context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "false");
}
if (!context.hasClassAvailable(QuarkusKogitoBuildContext.QUARKUS_DI)) {
LOGGER.info("Disabling dependency injection generation because class '" + QuarkusKogitoBuildContext.QUARKUS_DI + "' is not available");
context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_DI, "false");
}
return context;
}
use of io.quarkus.maven.dependency.Dependency in project quarkus by quarkusio.
the class InfoCommandHandler method resolveProjectState.
protected static ProjectState resolveProjectState(ApplicationModel appModel, ExtensionCatalog currentCatalog) {
final ProjectState.Builder projectBuilder = ProjectState.builder();
final Collection<ArtifactCoords> importedPlatformBoms = appModel.getPlatforms().getImportedPlatformBoms();
if (importedPlatformBoms.isEmpty()) {
return projectBuilder.build();
}
final Map<String, ExtensionProvider.Builder> extProviderBuilders = new LinkedHashMap<>(importedPlatformBoms.size());
importedPlatformBoms.forEach(bom -> {
projectBuilder.addPlatformBom(bom);
extProviderBuilders.put(ExtensionProvider.key(bom, true), ExtensionProvider.builder().setArtifact(bom).setPlatform(true));
});
final Map<WorkspaceModuleId, ModuleState.Builder> projectModuleBuilders = new HashMap<>();
final Map<ArtifactKey, List<ModuleState.Builder>> directModuleDeps = new HashMap<>();
final WorkspaceModule appModule = appModel.getAppArtifact().getWorkspaceModule();
if (appModule != null) {
final ModuleState.Builder module = ModuleState.builder().setWorkspaceModule(appModule).setMainModule(true);
projectModuleBuilders.put(appModule.getId(), module);
appModule.getDirectDependencies().forEach(d -> directModuleDeps.computeIfAbsent(d.getKey(), dk -> new ArrayList<>()).add(module));
for (Dependency constraint : appModule.getDirectDependencyConstraints()) {
if (extProviderBuilders.containsKey(constraint.toCompactCoords())) {
module.addPlatformBom(constraint);
}
}
}
for (ResolvedDependency dep : appModel.getDependencies()) {
if (dep.getWorkspaceModule() != null) {
projectModuleBuilders.computeIfAbsent(dep.getWorkspaceModule().getId(), k -> {
final ModuleState.Builder module = ModuleState.builder().setWorkspaceModule(dep.getWorkspaceModule());
dep.getWorkspaceModule().getDirectDependencies().forEach(d -> directModuleDeps.computeIfAbsent(d.getKey(), dk -> new ArrayList<>()).add(module));
return module;
});
}
}
final Map<ArtifactKey, TopExtensionDependency.Builder> directExtDeps = new HashMap<>();
for (ResolvedDependency dep : appModel.getDependencies()) {
if (dep.isFlagSet(DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT)) {
directExtDeps.put(dep.getKey(), TopExtensionDependency.builder().setResolvedDependency(dep).setTransitive(!directModuleDeps.containsKey(dep.getKey())));
} else if (dep.isRuntimeExtensionArtifact() && directModuleDeps.containsKey(dep.getKey())) {
directExtDeps.put(dep.getKey(), TopExtensionDependency.builder().setResolvedDependency(dep));
}
}
if (directExtDeps.isEmpty()) {
return projectBuilder.build();
}
currentCatalog.getExtensions().forEach(e -> {
final ArtifactKey key = e.getArtifact().getKey();
final TopExtensionDependency.Builder dep = directExtDeps.get(key);
if (dep != null) {
dep.setCatalogMetadata(e);
}
});
for (TopExtensionDependency.Builder extBuilder : directExtDeps.values()) {
final List<ModuleState.Builder> modules = directModuleDeps.getOrDefault(extBuilder.getKey(), Collections.emptyList());
final TopExtensionDependency dep = extBuilder.setTransitive(modules.isEmpty()).build();
projectBuilder.addExtensionDependency(dep);
for (ModuleState.Builder module : modules) {
module.addExtensionDependency(dep);
}
final ExtensionProvider.Builder provider = extProviderBuilders.computeIfAbsent(dep.getProviderKey(), k -> ExtensionProvider.builder().setOrigin(dep.getOrigin()));
provider.addExtension(dep);
}
for (ExtensionProvider.Builder builder : extProviderBuilders.values()) {
projectBuilder.addExtensionProvider(builder.build());
}
for (ModuleState.Builder builder : projectModuleBuilders.values()) {
projectBuilder.addModule(builder.build());
}
return projectBuilder.build();
}
use of io.quarkus.maven.dependency.Dependency in project quarkus by quarkusio.
the class JarResultBuildStep method walkFileDependencyForDependency.
private void walkFileDependencyForDependency(Path root, FileSystem runnerZipFs, Map<String, String> seen, Map<String, Set<Dependency>> duplicateCatcher, Map<String, List<byte[]>> concatenatedEntries, Predicate<String> ignoredEntriesPredicate, Dependency appDep, Set<String> existingEntries, Set<String> mergeResourcePaths) throws IOException {
final Path metaInfDir = root.resolve("META-INF");
Files.walkFileTree(root, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
final String relativePath = toUri(root.relativize(dir));
if (!relativePath.isEmpty()) {
addDir(runnerZipFs, relativePath);
}
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
final String relativePath = toUri(root.relativize(file));
// then we don't add it to the uber jar
if (isBlockOrSF(relativePath) && file.relativize(metaInfDir).getNameCount() == 1) {
if (log.isDebugEnabled()) {
log.debug("Signature file " + file.toAbsolutePath() + " from app " + "dependency " + appDep + " will not be included in uberjar");
}
return FileVisitResult.CONTINUE;
}
if (!existingEntries.contains(relativePath)) {
if (UBER_JAR_CONCATENATED_ENTRIES_PREDICATE.test(relativePath) || mergeResourcePaths.contains(relativePath)) {
concatenatedEntries.computeIfAbsent(relativePath, (u) -> new ArrayList<>()).add(Files.readAllBytes(file));
return FileVisitResult.CONTINUE;
} else if (!ignoredEntriesPredicate.test(relativePath)) {
duplicateCatcher.computeIfAbsent(relativePath, (a) -> new HashSet<>()).add(appDep);
if (!seen.containsKey(relativePath)) {
seen.put(relativePath, appDep.toString());
Files.copy(file, runnerZipFs.getPath(relativePath), StandardCopyOption.REPLACE_EXISTING);
}
}
}
return FileVisitResult.CONTINUE;
}
});
}
use of io.quarkus.maven.dependency.Dependency in project quarkus by quarkusio.
the class ConditionalDependencyScenarioTwoTest method assertAppModel.
@Override
protected void assertAppModel(ApplicationModel appModel) throws Exception {
final Set<Dependency> deploymentDeps = appModel.getDependencies().stream().filter(d -> d.isDeploymentCp() && !d.isRuntimeCp()).map(d -> new ArtifactDependency(d)).collect(Collectors.toSet());
final Set<Dependency> expected = new HashSet<>();
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-f-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-g-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-h-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-k-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-l-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-j-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-m-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-n-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-i-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-o-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-p-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-r-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-s-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-t-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-u-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
assertEquals(expected, new HashSet<>(deploymentDeps));
}
use of io.quarkus.maven.dependency.Dependency in project quarkus by quarkusio.
the class PackageAppTestBase method assertExtensionDependencies.
private static void assertExtensionDependencies(ApplicationModel appModel, String[] expectedExtensions) {
final Set<String> expectedRuntime = new HashSet<>(expectedExtensions.length);
final Set<String> expectedDeployment = new HashSet<>(expectedExtensions.length);
for (String rtId : expectedExtensions) {
expectedRuntime.add(TsArtifact.DEFAULT_GROUP_ID + ":" + rtId + "::jar:" + TsArtifact.DEFAULT_VERSION);
expectedDeployment.add(TsArtifact.DEFAULT_GROUP_ID + ":" + rtId + "-deployment" + "::jar:" + TsArtifact.DEFAULT_VERSION);
}
final Collection<ResolvedDependency> rtDeps = appModel.getRuntimeDependencies();
for (Dependency dep : rtDeps) {
final String coords = dep.toGACTVString();
assertTrue(expectedRuntime.contains(coords), coords);
}
assertEquals(expectedExtensions.length, rtDeps.size());
final List<Dependency> deploymentOnly = appModel.getDependencies().stream().filter(d -> d.isDeploymentCp() && !d.isRuntimeCp()).collect(Collectors.toList());
for (Dependency dep : deploymentOnly) {
final String coords = dep.toGACTVString();
assertTrue(expectedDeployment.contains(coords), coords);
}
assertEquals(expectedExtensions.length, deploymentOnly.size());
}
Aggregations