use of io.quarkus.bootstrap.model.AppArtifact in project quarkus-test-framework by quarkus-qe.
the class QuarkusApplicationManagedResourceBuilder method initForcedDependencies.
public void initForcedDependencies(Dependency[] forcedDependencies) {
if (forcedDependencies != null && forcedDependencies.length > 0) {
requiresCustomBuild = true;
this.forcedDependencies = Stream.of(forcedDependencies).map(d -> {
String groupId = StringUtils.defaultIfEmpty(resolveProperty(d.groupId()), QUARKUS_GROUP_ID_DEFAULT);
String version = StringUtils.defaultIfEmpty(resolveProperty(d.version()), Version.getVersion());
AppArtifact artifact = new AppArtifact(groupId, d.artifactId(), version);
// https://github.com/quarkusio/quarkus/commit/0c85b27c4046c894c181ffea367fca503d1c682c
if (isQuarkusVersion2Dot3OrAbove()) {
return ReflectionUtils.createInstance(AppDependency.class, artifact, DEPENDENCY_SCOPE_DEFAULT, new int[] { DEPENDENCY_DIRECT_FLAG });
}
return new AppDependency(artifact, DEPENDENCY_SCOPE_DEFAULT);
}).collect(Collectors.toList());
}
}
use of io.quarkus.bootstrap.model.AppArtifact in project quarkus by quarkusio.
the class BootstrapUtils method convert.
public static AppModel convert(ApplicationModel appModel) {
if (appModel instanceof AppModel) {
return (AppModel) appModel;
}
final AppModel.Builder builder = new AppModel.Builder();
final ResolvedDependency resolvedArtifact = appModel.getAppArtifact();
final AppArtifact appArtifact = new AppArtifact(resolvedArtifact.getGroupId(), resolvedArtifact.getArtifactId(), resolvedArtifact.getClassifier(), resolvedArtifact.getType(), resolvedArtifact.getVersion(), appModel.getApplicationModule(), resolvedArtifact.getScope(), resolvedArtifact.getFlags());
if (appModel.getAppArtifact().isResolved()) {
appArtifact.setPaths(PathsCollection.from(appModel.getAppArtifact().getResolvedPaths()));
}
builder.setAppArtifact(appArtifact);
builder.setCapabilitiesContracts(appModel.getExtensionCapabilities().stream().map(c -> new CapabilityContract(c.getExtension(), new ArrayList<>(c.getProvidesCapabilities()), new ArrayList<>(c.getRequiresCapabilities()))).collect(Collectors.toMap(CapabilityContract::getExtension, Function.identity())));
builder.setPlatformImports(appModel.getPlatforms());
appModel.getDependencies().forEach(d -> {
final AppArtifact a = new AppArtifact(d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion(), d.getWorkspaceModule(), d.getScope(), d.getFlags());
a.setPaths(d.getResolvedPaths() == null ? PathsCollection.of() : PathsCollection.from(d.getResolvedPaths()));
builder.addDependency(new AppDependency(a, d.getScope(), d.getFlags()));
});
appModel.getLowerPriorityArtifacts().forEach(k -> builder.addLesserPriorityArtifact(new AppArtifactKey(k.getGroupId(), k.getArtifactId(), k.getClassifier(), k.getType())));
appModel.getParentFirst().forEach(k -> builder.addParentFirstArtifact(new AppArtifactKey(k.getGroupId(), k.getArtifactId(), k.getClassifier(), k.getType())));
appModel.getRunnerParentFirst().forEach(k -> builder.addRunnerParentFirstArtifact(new AppArtifactKey(k.getGroupId(), k.getArtifactId(), k.getClassifier(), k.getType())));
appModel.getReloadableWorkspaceDependencies().forEach(k -> builder.addLocalProjectArtifact(new AppArtifactKey(k.getGroupId(), k.getArtifactId(), k.getClassifier(), k.getType())));
return builder.build();
}
use of io.quarkus.bootstrap.model.AppArtifact in project quarkus by quarkusio.
the class ModelUtils method getUpdateCandidates.
/**
* Filters out non-platform from application POM dependencies.
*
* @param deps POM model application dependencies
* @param appDeps resolved application dependencies
* @return dependencies that can be checked for updates
*/
public static List<AppDependency> getUpdateCandidates(List<Dependency> deps, List<AppDependency> appDeps, Set<String> groupIds) {
final Map<AppArtifactKey, AppDependency> appDepMap = new LinkedHashMap<>(appDeps.size());
for (AppDependency appDep : appDeps) {
final AppArtifact appArt = appDep.getArtifact();
appDepMap.put(new AppArtifactKey(appArt.getGroupId(), appArt.getArtifactId(), appArt.getClassifier()), appDep);
}
final List<AppDependency> updateCandidates = new ArrayList<>(deps.size());
// it's critical to preserve the order of the dependencies from the pom
for (Dependency dep : deps) {
if (!groupIds.contains(dep.getGroupId()) || "test".equals(dep.getScope())) {
continue;
}
final AppDependency appDep = appDepMap.remove(new AppArtifactKey(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier()));
if (appDep == null) {
// throw new AppCreatorException("Failed to locate dependency " + new AppArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(), dep.getType(), dep.getVersion()) + " present in pom.xml among resolved application dependencies");
continue;
}
updateCandidates.add(appDep);
}
for (AppDependency appDep : appDepMap.values()) {
if (groupIds.contains(appDep.getArtifact().getGroupId())) {
updateCandidates.add(appDep);
}
}
return updateCandidates;
}
use of io.quarkus.bootstrap.model.AppArtifact in project quarkus by quarkusio.
the class ModelUtils method resolveAppArtifact.
public static AppArtifact resolveAppArtifact(Path appJar) throws IOException {
try (FileSystem fs = ZipUtils.newFileSystem(appJar)) {
final Path metaInfMaven = fs.getPath("META-INF", "maven");
if (Files.exists(metaInfMaven)) {
try (DirectoryStream<Path> groupIds = Files.newDirectoryStream(metaInfMaven)) {
for (Path groupIdPath : groupIds) {
if (!Files.isDirectory(groupIdPath)) {
continue;
}
try (DirectoryStream<Path> artifactIds = Files.newDirectoryStream(groupIdPath)) {
for (Path artifactIdPath : artifactIds) {
if (!Files.isDirectory(artifactIdPath)) {
continue;
}
final Path propsPath = artifactIdPath.resolve("pom.properties");
if (Files.exists(propsPath)) {
final Properties props = loadPomProps(appJar, artifactIdPath);
AppArtifact appArtifact = new AppArtifact(props.getProperty("groupId"), props.getProperty("artifactId"), props.getProperty("version"));
appArtifact.setPath(appJar);
return appArtifact;
}
}
}
}
}
}
AppArtifact appArtifact = new AppArtifact("unknown", "unknown", "1.0-SNAPSHOT");
appArtifact.setPath(appJar);
return appArtifact;
}
}
Aggregations