Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues when using WildFly channel #75

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions core/src/main/java/org/wildfly/glow/GlowSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.jboss.galleon.api.config.GalleonProvisioningConfig;
import org.jboss.galleon.universe.UniverseResolver;
import org.wildfly.channel.ChannelSession;
import org.wildfly.channel.NoStreamFoundException;
import org.wildfly.channel.VersionResult;
import static org.wildfly.glow.error.ErrorLevel.ERROR;
import org.wildfly.plugin.tools.bootablejar.BootableJarSupport;
Expand Down Expand Up @@ -164,9 +165,9 @@ public ScanResults scan() throws Exception {
} else {
provisioning = provider.newProvisioningBuilder(config).setInstallationHome(fakeHome).build();
}
GalleonProvisioningConfig inputConfig = config;
// Channel handling
Map<ProducerSpec, FPID> fpVersions = new HashMap<>();
Map<ProducerSpec, FPID> resolvedInChannel = new HashMap<>();
if (arguments.getChannelSession() != null) {
ChannelSession channelSession = arguments.getChannelSession();
// Compute versions based on channel.
Expand All @@ -176,11 +177,18 @@ public ScanResults scan() throws Exception {
String[] coordinates = fpid.toString().split(":");
String groupId = coordinates[0];
String artifactId = coordinates[1];
VersionResult res = channelSession.findLatestMavenArtifactVersion(groupId, artifactId,
FeaturePackLocation loc;
try {
VersionResult res = channelSession.findLatestMavenArtifactVersion(groupId, artifactId,
"zip", null, null);
FeaturePackLocation loc = dep.getLocation().replaceBuild(res.getVersion());
loc = dep.getLocation().replaceBuild(res.getVersion());
} catch(NoStreamFoundException ex) {
writer.warn("WARNING: Feature-pack " + dep.getLocation() + " is not present in the configured channel, ignoring it.");
continue;
}
outputConfigBuilder.addFeaturePackDep(loc);
fpVersions.put(fpid.getProducer(), loc.getFPID());
resolvedInChannel.put(fpid.getProducer(), loc.getFPID());
}
config = outputConfigBuilder.build();
} else {
Expand Down Expand Up @@ -527,8 +535,8 @@ public ScanResults scan() throws Exception {
envs.addAll(stronglySuggestConfigFixes.get(l));
}
// Identify the active feature-packs.
GalleonProvisioningConfig activeConfig = buildProvisioningConfig(inputConfig,
universeResolver, allBaseLayers, baseLayer, decorators, excludedLayers, fpDependencies, arguments.getConfigName(), arguments.getConfigStability(), arguments.getPackageStability());
GalleonProvisioningConfig activeConfig = buildProvisioningConfig(config,
universeResolver, allBaseLayers, baseLayer, decorators, excludedLayers, fpDependencies, arguments.getConfigName(), arguments.getConfigStability(), arguments.getPackageStability(), resolvedInChannel);

// Handle stability
if (arguments.getConfigStability() != null) {
Expand Down Expand Up @@ -954,7 +962,7 @@ private static GalleonProvisioningConfig buildProvisioningConfig(GalleonProvisio
Set<Layer> decorators,
Set<Layer> excludedLayers,
Map<FeaturePackLocation.FPID, Set<FeaturePackLocation.ProducerSpec>> fpDependencies,
String configName, String configStability, String packageStability) throws ProvisioningException {
String configName, String configStability, String packageStability, Map<ProducerSpec, FPID> channelVersions) throws ProvisioningException {
Map<ProducerSpec, GalleonFeaturePackConfig> map = new HashMap<>();
Map<ProducerSpec, FPID> universeToGav = new HashMap<>();
for (GalleonFeaturePackConfig cfg : input.getFeaturePackDeps()) {
Expand Down Expand Up @@ -986,6 +994,11 @@ private static GalleonProvisioningConfig buildProvisioningConfig(GalleonProvisio
FeaturePackLocation.FPID gav = universeToGav.get(cfg.getLocation().getProducer());
FeaturePackLocation.FPID fpid = tmpFps.get(gav.getProducer());
if (fpid != null) {
// Reset the version if ruled by channel
FPID orig = channelVersions.get(cfg.getLocation().getProducer());
if ( orig != null && orig.getLocation().isMavenCoordinates()) {
gav = gav.getLocation().replaceBuild("").getFPID();
}
activeFeaturePacks.add(gav);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ private void resolveFromChannels(MavenArtifact artifact) throws UnresolvedMavenA

@Override
public void resolveLatestVersion(MavenArtifact artifact) throws MavenUniverseException {
throw new MavenUniverseException("Channel resolution can't be applied to Galleon universe");
// To resolve community universe
MavenRepoManager resolver = MavenResolver.newMavenResolver();
resolver.resolveLatestVersion(artifact);
}

@Override
Expand All @@ -92,13 +94,17 @@ public boolean isLatestVersionResolved(MavenArtifact artifact, String lowestQual
@Override
public void resolveLatestVersion(MavenArtifact artifact, String lowestQualifier, Pattern includeVersion,
Pattern excludeVersion) throws MavenUniverseException {
throw new MavenUniverseException("Channel resolution can't be applied to Galleon universe");
// To resolve community universe
MavenRepoManager resolver = MavenResolver.newMavenResolver();
resolver.resolveLatestVersion(artifact, lowestQualifier, includeVersion, excludeVersion);
}

@Override
public void resolveLatestVersion(MavenArtifact artifact, String lowestQualifier, boolean locallyAvailable)
throws MavenUniverseException {
throw new MavenUniverseException("Channel resolution can't be applied to Galleon universe");
// To resolve community universe
MavenRepoManager resolver = MavenResolver.newMavenResolver();
resolver.resolveLatestVersion(artifact, lowestQualifier, locallyAvailable);
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions tests/run-cli-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ if [ $? -ne 0 ]; then
exit 1
fi

echo Provision a server with a channel
java -jar $jar scan examples/war/kitchensink.war --provision=SERVER --channels tests/wildfly-29.0.0.Final-channel.yaml

if [ $? -ne 0 ]; then
echo "Error, check log"
exit 1
fi

echo Provision a bootable JAR
java -jar $jar scan examples/war/kitchensink.war --provision=BOOTABLE_JAR

Expand Down
9 changes: 9 additions & 0 deletions tests/wildfly-29.0.0.Final-channel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
schemaVersion: "2.0.0"
name: wildfly-test
repositories:
- id: "central"
url: "https://repo1.maven.org/maven2/"
- id: "jboss-public"
url: "https://repository.jboss.org/nexus/content/groups/public/"
manifest:
url: "file:tests/wildfly-29.0.0.Final-manifest.yaml"
Loading
Loading