forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31afcb2
commit e61ee3f
Showing
22 changed files
with
2,476 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
...s/devtools-common/src/main/java/io/quarkus/devtools/project/state/ConfiguredArtifact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
.../tools/devtools-common/src/main/java/io/quarkus/devtools/project/state/ConfiguredBom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
...ols/devtools-common/src/main/java/io/quarkus/devtools/project/state/ConfiguredModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.