Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Nov 3, 2023
1 parent 31afcb2 commit e61ee3f
Show file tree
Hide file tree
Showing 22 changed files with 2,476 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public CollectResult collectManagedDependencies(Artifact artifact, List<Dependen
throws BootstrapMavenException {
try {
return repoSystem.collectDependencies(repoSession,
newCollectManagedRequest(artifact, List.of(), managedDeps, mainRepos, exclusions, Set.of(excludedScopes)));
newCollectManagedRequest(artifact, directDeps, managedDeps, mainRepos, exclusions, Set.of(excludedScopes)));
} catch (DependencyCollectionException e) {
throw new BootstrapMavenException("Failed to collect dependencies for " + artifact, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static Artifact toArtifact(String str) {
private static Artifact toArtifact(String str, int offset) {
String groupId = null;
String artifactId = null;
String classifier = "";
String classifier = ArtifactCoords.DEFAULT_CLASSIFIER;
String type = ArtifactCoords.TYPE_JAR;
String version = null;

Expand Down
51 changes: 51 additions & 0 deletions independent-projects/tools/devtools-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,59 @@
</testResource>
</testResources>
</build>
<!--
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-recipe-bom</artifactId>
<version>1.14.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.xml.bind</groupId>
<artifactId>jboss-jaxb-api_2.3_spec</artifactId>
<version>${jboss-jaxb-api_2.3_spec.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
-->
<dependencies>
<!--
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-maven</artifactId>
<exclusions>
<exclusion>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</exclusion>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.xml.bind</groupId>
<artifactId>jboss-jaxb-api_2.3_spec</artifactId>
</dependency>
-->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devtools-registry-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
package io.quarkus.devtools.project.state;

import java.util.Objects;

import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.maven.dependency.ArtifactKey;

public class ConfiguredArtifact {

public static ConfiguredArtifact jar(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue version) {
return jar(groupId, artifactId, version, false);
}

public static ConfiguredArtifact jar(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue version,
boolean local) {
return of(groupId, artifactId, ConfiguredValue.of(ArtifactCoords.DEFAULT_CLASSIFIER),
ConfiguredValue.of(ArtifactCoords.TYPE_JAR), version, local);
}

public static ConfiguredArtifact pom(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue version) {
return pom(groupId, artifactId, version, false);
}

public static ConfiguredArtifact pom(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue version,
boolean local) {
return of(groupId, artifactId, ConfiguredValue.of(ArtifactCoords.DEFAULT_CLASSIFIER),
ConfiguredValue.of(ArtifactCoords.TYPE_POM), version, local);
}

public static ConfiguredArtifact of(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue classifier,
ConfiguredValue type, ConfiguredValue version) {
return of(groupId, artifactId, classifier, type, version, false);
}

public static ConfiguredArtifact of(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue classifier,
ConfiguredValue type, ConfiguredValue version, boolean local) {
return new ConfiguredArtifact(groupId, artifactId, classifier, type, version, local);
}

private final ConfiguredValue groupId;
private final ConfiguredValue artifactId;
private final ConfiguredValue classifier;
private final ConfiguredValue type;
private final ConfiguredValue version;
private final boolean local;
private ArtifactKey key;

private ConfiguredArtifact(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue classifier,
ConfiguredValue type, ConfiguredValue version, boolean local) {
super();
this.groupId = groupId;
this.artifactId = artifactId;
this.classifier = classifier;
this.type = type;
this.version = version;
this.local = local;
}

public ConfiguredValue getGroupId() {
return groupId;
}

public ConfiguredValue getArtifactId() {
return artifactId;
}

public ConfiguredValue getClassifier() {
return classifier;
}

public ConfiguredValue getType() {
return type;
}

public ConfiguredValue getVersion() {
return version;
}

public boolean isLocal() {
return local;
}

public boolean isManagedVersion() {
return version.getRawValue() == null || version.getRawValue().isEmpty();
}

public ArtifactCoords getRawCoords() {
return ArtifactCoords.of(groupId.getRawValue(), artifactId.getRawValue(), classifier.getRawValue(),
type.getRawValue(), version.getRawValue());
}

public ArtifactCoords getEffectiveCoords() {
return ArtifactCoords.of(groupId.getEffectiveValue(), artifactId.getEffectiveValue(), classifier.getEffectiveValue(),
type.getEffectiveValue(), version.getEffectiveValue());
}

public ArtifactKey getKey() {
return key == null
? key = ArtifactKey.of(groupId.getEffectiveValue(), artifactId.getEffectiveValue(),
classifier.getEffectiveValue(), type.getEffectiveValue())
: key;
}

@Override
public int hashCode() {
return Objects.hash(artifactId, classifier, groupId, key, local, type, version);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ConfiguredArtifact other = (ConfiguredArtifact) obj;
return Objects.equals(artifactId, other.artifactId) && Objects.equals(classifier, other.classifier)
&& Objects.equals(groupId, other.groupId) && Objects.equals(key, other.key) && local == other.local
&& Objects.equals(type, other.type) && Objects.equals(version, other.version);
}

public String toCompactString() {
final StringBuilder sb = new StringBuilder()
.append(groupId).append(':')
.append(artifactId).append(':');
if (!classifier.isEffectivelyNull() && !classifier.getEffectiveValue().isEmpty()) {
sb.append(classifier).append(':');
}
if (type.isEffectivelyNull() && !ArtifactCoords.TYPE_JAR.equals(type.getEffectiveValue())) {
sb.append(type).append(':');
}
sb.append(version);
if (local) {
sb.append("[local]");
}
return sb.toString();
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder()
.append(groupId).append(':')
.append(artifactId).append(':')
.append(classifier).append(':')
.append(type).append(':')
.append(version);
if (local) {
sb.append("[local]");
}
return sb.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.quarkus.devtools.project.state;

import java.util.Objects;

public class ConfiguredBom {

public static ConfiguredBom enforced(ConfiguredArtifact pom) {
return new ConfiguredBom(pom, false);
}

public static ConfiguredBom enforced(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue version,
boolean local) {
return new ConfiguredBom(ConfiguredArtifact.pom(groupId, artifactId, version, local), false);
}

public static ConfiguredBom imported(ConfiguredValue groupId, ConfiguredValue artifactId, ConfiguredValue version,
boolean local) {
return new ConfiguredBom(ConfiguredArtifact.pom(groupId, artifactId, version, local), true);
}

private final ConfiguredArtifact bom;
private final boolean imported;

private ConfiguredBom(ConfiguredArtifact bom, boolean imported) {
super();
this.bom = bom;
this.imported = imported;
}

public ConfiguredArtifact getArtifact() {
return bom;
}

public boolean isImported() {
return imported;
}

@Override
public int hashCode() {
return Objects.hash(bom, imported);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ConfiguredBom other = (ConfiguredBom) obj;
return Objects.equals(bom, other.bom) && imported == other.imported;
}

@Override
public String toString() {
return (imported ? "imported " : "enforced ") + bom.toCompactString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package io.quarkus.devtools.project.state;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import io.quarkus.bootstrap.workspace.WorkspaceModuleId;
import io.quarkus.maven.dependency.ArtifactCoords;

public class ConfiguredModule {

public static ConfiguredModule of(WorkspaceModuleId id, Path buildFile) {
return new ConfiguredModule(id, buildFile);
}

private final WorkspaceModuleId id;
private final Path buildFile;
private final Map<ArtifactCoords, ConfiguredBom> platformBoms = new LinkedHashMap<>();
private final Map<ArtifactCoords, ConfiguredArtifact> managedExtensions = new LinkedHashMap<>();
private final List<ConfiguredArtifact> directExtensionDeps = new ArrayList<>();
private final List<ConfiguredArtifact> topTransitiveExtensionDeps = new ArrayList<>(0);
private ConfiguredArtifact quarkusPlugin;
private ConfiguredArtifact managedQuarkusPlugin;
private boolean quarkusApp;

private ConfiguredModule(WorkspaceModuleId id, Path buildFile) {
this.id = id;
this.buildFile = buildFile;
}

public WorkspaceModuleId getId() {
return id;
}

public Path getBuildFile() {
return buildFile;
}

public void addPlatformBom(ConfiguredBom bom) {
platformBoms.put(bom.getArtifact().getEffectiveCoords(), bom);
}

public Collection<ConfiguredBom> getPlatformBoms() {
return platformBoms.values();
}

public void addManagedExtension(ConfiguredArtifact directExtensionDep) {
managedExtensions.put(directExtensionDep.getEffectiveCoords(), directExtensionDep);
}

public Collection<ConfiguredArtifact> getManagedExtensions() {
return managedExtensions.values();
}

public void addDirectExtensionDep(ConfiguredArtifact directExtensionDep) {
directExtensionDeps.add(directExtensionDep);
}

public List<ConfiguredArtifact> getDirectExtensionDeps() {
return directExtensionDeps;
}

public void addTopTransitiveExtensionDep(ConfiguredArtifact extensionDep) {
topTransitiveExtensionDeps.add(extensionDep);
}

public List<ConfiguredArtifact> getTopTransitiveExtensionDeps() {
return topTransitiveExtensionDeps;
}

public void setQuarkusPlugin(ConfiguredArtifact plugin) {
this.quarkusPlugin = plugin;
}

public ConfiguredArtifact getQuarkusPlugin() {
return quarkusPlugin;
}

public void setManagedQuarkusPlugin(ConfiguredArtifact plugin) {
this.managedQuarkusPlugin = plugin;
}

public ConfiguredArtifact getManagedQuarkusPlugin() {
return managedQuarkusPlugin;
}

public void setQuarkusApplication(boolean quarkusApp) {
this.quarkusApp = quarkusApp;
}

public boolean isQuarkusApplication() {
return quarkusApp;
}
}
Loading

0 comments on commit e61ee3f

Please sign in to comment.