Skip to content

Commit

Permalink
Merge pull request quarkusio#41939 from gastaldi/appmodel
Browse files Browse the repository at this point in the history
Remove deprecated classes from app-model
  • Loading branch information
aloubyansky authored Jul 17, 2024
2 parents 4de65bb + 700f48d commit 731c915
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 674 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import org.jboss.jandex.IndexView;

import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.maven.dependency.ResolvedDependency;
Expand Down Expand Up @@ -72,12 +71,6 @@ public interface ApplicationArchive {
*/
PathCollection getResolvedPaths();

/**
* @deprecated in favor of {@link #getKey()}
* @return the artifact key or null if not available
*/
AppArtifactKey getArtifactKey();

/**
*
* @return the artifact key or null if not available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.jboss.jandex.IndexView;

import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.maven.dependency.ArtifactKey;
Expand Down Expand Up @@ -62,21 +61,6 @@ public PathCollection getResolvedPaths() {
return PathList.from(openTree.getOriginalTree().getRoots());
}

@Override
@Deprecated
/**
* @deprecated in favor of {@link #getKey()}
* @return archive key
*/
public AppArtifactKey getArtifactKey() {
if (resolvedDependency == null) {
return null;
}
ArtifactKey artifactKey = resolvedDependency.getKey();
return new AppArtifactKey(artifactKey.getGroupId(), artifactKey.getArtifactId(), artifactKey.getClassifier(),
artifactKey.getType());
}

@Override
public ArtifactKey getKey() {
return resolvedDependency != null ? resolvedDependency.getKey() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;

Expand All @@ -36,14 +37,13 @@
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

import io.quarkus.bootstrap.BootstrapConstants;
import io.quarkus.bootstrap.model.AppArtifactCoords;
import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.bootstrap.model.ApplicationModelBuilder;
import io.quarkus.devtools.project.extensions.ScmInfoProvider;
import io.quarkus.extension.gradle.QuarkusExtensionConfiguration;
import io.quarkus.extension.gradle.dsl.Capability;
import io.quarkus.extension.gradle.dsl.RemovedResource;
import io.quarkus.fs.util.ZipUtils;
import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.maven.dependency.GACT;

Expand Down Expand Up @@ -113,9 +113,9 @@ private void generateQuarkusExtensionProperties(Path metaInfDir) {
if (conditionalDependencies != null && !conditionalDependencies.isEmpty()) {
final StringBuilder buf = new StringBuilder();
int i = 0;
buf.append(AppArtifactCoords.fromString(conditionalDependencies.get(i++)).toString());
buf.append(ArtifactCoords.fromString(conditionalDependencies.get(i++)));
while (i < conditionalDependencies.size()) {
buf.append(' ').append(AppArtifactCoords.fromString(conditionalDependencies.get(i++)).toString());
buf.append(' ').append(ArtifactCoords.fromString(conditionalDependencies.get(i++)));
}
props.setProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES, buf.toString());
}
Expand Down Expand Up @@ -315,7 +315,7 @@ private void computeArtifactCoords(ObjectNode extObject) {
}
}
if (artifactNode == null || groupId == null || artifactId == null || version == null) {
final AppArtifactCoords coords = new AppArtifactCoords(
final ArtifactCoords coords = ArtifactCoords.of(
groupId == null ? projectInfo.get("group") : groupId,
artifactId == null ? projectInfo.get("name") : artifactId,
null,
Expand Down Expand Up @@ -363,7 +363,7 @@ private void computeQuarkusExtensions(ObjectNode extObject) {
ObjectNode metadataNode = getMetadataNode(extObject);
Set<ResolvedArtifact> extensions = new HashSet<>();
for (ResolvedArtifact resolvedArtifact : getClasspath().getResolvedConfiguration().getResolvedArtifacts()) {
if (resolvedArtifact.getExtension().equals("jar")) {
if (Objects.equals(resolvedArtifact.getExtension(), "jar")) {
Path p = resolvedArtifact.getFile().toPath();
if (Files.isDirectory(p) && isExtension(p)) {
extensions.add(resolvedArtifact);
Expand All @@ -382,7 +382,7 @@ private void computeQuarkusExtensions(ObjectNode extObject) {
for (ResolvedArtifact extension : extensions) {
ModuleVersionIdentifier id = extension.getModuleVersion().getId();
extensionArray
.add(new AppArtifactKey(id.getGroup(), id.getName(), extension.getClassifier(), extension.getExtension())
.add(ArtifactKey.of(id.getGroup(), id.getName(), extension.getClassifier(), extension.getExtension())
.toGacString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;

import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.extension.gradle.QuarkusExtensionConfiguration;
import io.quarkus.gradle.tooling.dependency.ArtifactExtensionDependency;
import io.quarkus.gradle.tooling.dependency.DependencyUtils;
import io.quarkus.gradle.tooling.dependency.ExtensionDependency;
import io.quarkus.gradle.tooling.dependency.ProjectExtensionDependency;
import io.quarkus.maven.dependency.ArtifactKey;

public class ValidateExtensionTask extends DefaultTask {

Expand Down Expand Up @@ -59,12 +59,12 @@ public void setDeploymentModuleClasspath(Configuration deploymentModuleClasspath
public void validateExtension() {
Set<ResolvedArtifact> runtimeArtifacts = getRuntimeModuleClasspath().getResolvedConfiguration().getResolvedArtifacts();

List<AppArtifactKey> deploymentModuleKeys = collectRuntimeExtensionsDeploymentKeys(runtimeArtifacts);
List<AppArtifactKey> invalidRuntimeArtifacts = findExtensionInConfiguration(runtimeArtifacts, deploymentModuleKeys);
List<ArtifactKey> deploymentModuleKeys = collectRuntimeExtensionsDeploymentKeys(runtimeArtifacts);
List<ArtifactKey> invalidRuntimeArtifacts = findExtensionInConfiguration(runtimeArtifacts, deploymentModuleKeys);

Set<ResolvedArtifact> deploymentArtifacts = getDeploymentModuleClasspath().getResolvedConfiguration()
.getResolvedArtifacts();
List<AppArtifactKey> existingDeploymentModuleKeys = findExtensionInConfiguration(deploymentArtifacts,
List<ArtifactKey> existingDeploymentModuleKeys = findExtensionInConfiguration(deploymentArtifacts,
deploymentModuleKeys);
deploymentModuleKeys.removeAll(existingDeploymentModuleKeys);

Expand All @@ -81,64 +81,60 @@ public void validateExtension() {
}
}

private List<AppArtifactKey> collectRuntimeExtensionsDeploymentKeys(Set<ResolvedArtifact> runtimeArtifacts) {
List<AppArtifactKey> runtimeExtensions = new ArrayList<>();
private List<ArtifactKey> collectRuntimeExtensionsDeploymentKeys(Set<ResolvedArtifact> runtimeArtifacts) {
List<ArtifactKey> runtimeExtensions = new ArrayList<>();
for (ResolvedArtifact resolvedArtifact : runtimeArtifacts) {
ExtensionDependency<?> extension = DependencyUtils.getExtensionInfoOrNull(getProject(), resolvedArtifact);
if (extension != null) {
if (extension instanceof ProjectExtensionDependency) {
final ProjectExtensionDependency ped = (ProjectExtensionDependency) extension;

if (extension instanceof ProjectExtensionDependency ped) {
runtimeExtensions
.add(new AppArtifactKey(ped.getDeploymentModule().getGroup().toString(),
.add(ArtifactKey.ga(ped.getDeploymentModule().getGroup().toString(),
ped.getDeploymentModule().getName()));
} else if (extension instanceof ArtifactExtensionDependency) {
final ArtifactExtensionDependency aed = (ArtifactExtensionDependency) extension;

runtimeExtensions.add(new AppArtifactKey(aed.getDeploymentModule().getGroupId(),
} else if (extension instanceof ArtifactExtensionDependency aed) {
runtimeExtensions.add(ArtifactKey.ga(aed.getDeploymentModule().getGroupId(),
aed.getDeploymentModule().getArtifactId()));
}
}
}
return runtimeExtensions;
}

private List<AppArtifactKey> findExtensionInConfiguration(Set<ResolvedArtifact> deploymentArtifacts,
List<AppArtifactKey> extensions) {
List<AppArtifactKey> foundExtensions = new ArrayList<>();
private List<ArtifactKey> findExtensionInConfiguration(Set<ResolvedArtifact> deploymentArtifacts,
List<ArtifactKey> extensions) {
List<ArtifactKey> foundExtensions = new ArrayList<>();

for (ResolvedArtifact deploymentArtifact : deploymentArtifacts) {
AppArtifactKey key = toAppArtifactKey(deploymentArtifact.getModuleVersion());
ArtifactKey key = toArtifactKey(deploymentArtifact.getModuleVersion());
if (extensions.contains(key)) {
foundExtensions.add(key);
}
}
return foundExtensions;
}

private void printValidationErrors(List<AppArtifactKey> invalidRuntimeArtifacts,
List<AppArtifactKey> missingDeploymentArtifacts) {
private void printValidationErrors(List<ArtifactKey> invalidRuntimeArtifacts,
List<ArtifactKey> missingDeploymentArtifacts) {
Logger log = getLogger();
log.error("Quarkus Extension Dependency Verification Error");

if (!invalidRuntimeArtifacts.isEmpty()) {
log.error("The following deployment artifact(s) appear on the runtime classpath: ");
for (AppArtifactKey invalidRuntimeArtifact : invalidRuntimeArtifacts) {
for (ArtifactKey invalidRuntimeArtifact : invalidRuntimeArtifacts) {
log.error("- " + invalidRuntimeArtifact);
}
}

if (!missingDeploymentArtifacts.isEmpty()) {
log.error("The following deployment artifact(s) were found to be missing in the deployment module: ");
for (AppArtifactKey missingDeploymentArtifact : missingDeploymentArtifacts) {
for (ArtifactKey missingDeploymentArtifact : missingDeploymentArtifacts) {
log.error("- " + missingDeploymentArtifact);
}
}

throw new GradleException("Quarkus Extension Dependency Verification Error. See logs below");
}

private static AppArtifactKey toAppArtifactKey(ResolvedModuleVersion artifactId) {
return new AppArtifactKey(artifactId.getId().getGroup(), artifactId.getId().getName());
private static ArtifactKey toArtifactKey(ResolvedModuleVersion artifactId) {
return ArtifactKey.ga(artifactId.getId().getGroup(), artifactId.getId().getName());
}
}

This file was deleted.

Loading

0 comments on commit 731c915

Please sign in to comment.