From 266e29a4136e18ffe47376cc0aec3c4c5ff62f78 Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Wed, 19 Jul 2023 11:22:22 +0200 Subject: [PATCH 1/3] Fix for #365, Do not perform artifact resolution fallback if the channel resolution failed due to transfer error --- ...ChannelMavenArtifactRepositoryManager.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelMavenArtifactRepositoryManager.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelMavenArtifactRepositoryManager.java index 9bfbeba1..ec3553f7 100644 --- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelMavenArtifactRepositoryManager.java +++ b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelMavenArtifactRepositoryManager.java @@ -43,9 +43,11 @@ import org.jboss.galleon.universe.maven.MavenUniverseException; import org.jboss.galleon.universe.maven.repo.MavenRepoManager; import org.jboss.galleon.util.ZipUtils; +import org.wildfly.channel.ArtifactTransferException; import org.wildfly.channel.Channel; import org.wildfly.channel.ChannelManifest; import org.wildfly.channel.ChannelSession; +import org.wildfly.channel.NoStreamFoundException; import org.wildfly.channel.Repository; import org.wildfly.channel.UnresolvedMavenArtifactException; import org.wildfly.channel.maven.VersionResolverFactory; @@ -99,7 +101,9 @@ public ChannelMavenArtifactRepositoryManager(List channels public void resolve(MavenArtifact artifact) throws MavenUniverseException { try { resolveFromChannels(artifact); - } catch (UnresolvedMavenArtifactException ex) { + } catch (ArtifactTransferException ex) { + throw new MavenUniverseException(ex.getLocalizedMessage(), ex); + } catch (NoStreamFoundException ex) { boolean requireChannel = Boolean.parseBoolean(artifact.getMetadata().get(REQUIRE_CHANNEL_FOR_ALL_ARTIFACT)); if (!requireChannel) { // Could be a feature-pack that could require to be resolved from a channel. @@ -112,8 +116,8 @@ public void resolve(MavenArtifact artifact) throws MavenUniverseException { } } if (!requireChannel) { - log.warn("Resolution of artifact " + artifact.getGroupId() + ":" - + artifact.getArtifactId() + " failed using configured channels. Using original version."); + log.warn("Resolution of artifact " + artifact.getGroupId() + ":" + + artifact.getArtifactId() + " failed using configured channels. Using original version."); // unable to resolve the artifact through the channel. // if the version is defined, let's resolve it directly if (artifact.getVersion() == null) { @@ -121,10 +125,12 @@ public void resolve(MavenArtifact artifact) throws MavenUniverseException { throw new MavenUniverseException(ex.getLocalizedMessage(), ex); } try { - log.warn("Using version " + artifact.getVersion() - + " to resolve artifact " + artifact.getGroupId() + ":" - + artifact.getArtifactId()); - org.wildfly.channel.MavenArtifact mavenArtifact = channelSession.resolveDirectMavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), artifact.getVersion()); + log.warn("Using version " + artifact.getVersion() + + " to resolve artifact " + artifact.getGroupId() + ":" + + artifact.getArtifactId()); + org.wildfly.channel.MavenArtifact mavenArtifact = channelSession.resolveDirectMavenArtifact( + artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), + artifact.getVersion()); artifact.setPath(mavenArtifact.getFile().toPath()); } catch (UnresolvedMavenArtifactException e) { // if the artifact can not be resolved directly either, we abort @@ -138,16 +144,16 @@ public void resolve(MavenArtifact artifact) throws MavenUniverseException { private boolean fpRequireChannel(MavenArtifact artifact) throws Exception { boolean requireChannel = false; - if (artifact.getVersion() != null && artifact.getExtension() != null && artifact.getExtension().equalsIgnoreCase("zip")) { - org.wildfly.channel.MavenArtifact mavenArtifact = channelSession. - resolveDirectMavenArtifact(artifact.getGroupId(), - artifact.getArtifactId(), - artifact.getExtension(), - artifact.getClassifier(), - artifact.getVersion()); + if (artifact.getVersion() != null && artifact.getExtension() != null + && artifact.getExtension().equalsIgnoreCase("zip")) { + org.wildfly.channel.MavenArtifact mavenArtifact = channelSession.resolveDirectMavenArtifact(artifact.getGroupId(), + artifact.getArtifactId(), + artifact.getExtension(), + artifact.getClassifier(), + artifact.getVersion()); try { FeaturePackDescriber.readSpec(mavenArtifact.getFile().toPath()); - } catch(ProvisioningException ex) { + } catch (ProvisioningException ex) { // Not a feature-pack return requireChannel; } @@ -157,7 +163,7 @@ private boolean fpRequireChannel(MavenArtifact artifact) throws Exception { final Path channelPropsPath = wfRes.resolve("wildfly-channel.properties"); if (Files.exists(channelPropsPath)) { Properties props = new Properties(); - try(BufferedReader reader = Files.newBufferedReader(channelPropsPath)) { + try (BufferedReader reader = Files.newBufferedReader(channelPropsPath)) { props.load(reader); } String resolution = props.getProperty("resolution"); From bb401b52e7dec58c5f47b1ac00978cb1401adbed Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Wed, 19 Jul 2023 13:08:25 +0200 Subject: [PATCH 2/3] Fix BootLoggingConfiguration generation to contain keyOverrides --- .../maven/goals/BootLoggingConfiguration.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/BootLoggingConfiguration.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/BootLoggingConfiguration.java index 6ef4bbda..e6df4522 100644 --- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/BootLoggingConfiguration.java +++ b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/BootLoggingConfiguration.java @@ -96,7 +96,7 @@ public class BootLoggingConfiguration { //extends AbstractLogEnabled { "user.dir", "user.home" ); - + private static final String KEY_OVERRIDES = "keyOverrides"; private final Map properties; private final Map usedProperties; private final Map additionalPatternFormatters; @@ -335,18 +335,19 @@ private void writeStructuredFormatter(final String type, final Writer writer, final ModelNode model = property.getValue().clone(); final String prefix = "formatter." + name; writeProperty(writer, prefix, null, type); - + boolean needKeyOverrides = !model.hasDefined("key-overrides"); // The key-overrides are used as constructor parameters - if (model.hasDefined("key-overrides")) { - writeProperty(writer, prefix, "constructorProperties", "keyOverrides"); - } - + // This property is alwasy added. + writeProperty(writer, prefix, "constructorProperties", KEY_OVERRIDES); // Next we need to write the properties final Collection definedPropertyNames = model.asPropertyList() .stream() .filter((p) -> p.getValue().isDefined()) .map(Property::getName) .collect(Collectors.toList()); + if (needKeyOverrides) { + definedPropertyNames.add(KEY_OVERRIDES); + } writeProperty(writer, prefix, "properties", toCsvString(definedPropertyNames .stream() .map(BootLoggingConfiguration::resolvePropertyName) @@ -359,7 +360,12 @@ private void writeStructuredFormatter(final String type, final Writer writer, if ("exception-output-type".equals(attributeName)) { writeProperty(writer, prefix, resolvePropertyName(attributeName), toEnumString(model.get(attributeName))); } else { - writeProperty(writer, prefix, resolvePropertyName(attributeName), value); + if (needKeyOverrides && KEY_OVERRIDES.equals(attributeName)) { + // The value is empty if explicitely added. + writeProperty(writer, prefix, resolvePropertyName(attributeName), ""); + } else { + writeProperty(writer, prefix, resolvePropertyName(attributeName), value); + } } } writer.write(NEW_LINE); From 792a12d7905e8bf065d19ca4202fde5f0319275b Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Fri, 17 Nov 2023 09:25:18 +0100 Subject: [PATCH 3/3] Upgrade wf-core, wf-common, galleon, prospero, wf-channel, maven plugin tools, jboss-logging --- pom.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index c9515f76..40a49753 100644 --- a/pom.xml +++ b/pom.xml @@ -61,20 +61,20 @@ 4.13.1 1.0.0.Alpha3 3.8.4 - 3.6.4 - 3.6.4 + 3.7.0 + 3.7.0 2.0.0 - 5.1.0.Final - 20.0.1.Final - 1.5.4.Final - 4.1.0.Final - 1.0.0.Final - 1.0.0.Final + 5.1.2.Final + 20.0.2.Final + 1.6.0.Final + 4.1.1.Final + 1.0.5.Final + 1.1.5.Final 3.0.0-M6 4.5.13 1.1.0 - 1.1.0.Final + 1.2.1.Final 3.3.0 1.2.6