From 398484c4851da9750a4bb612fd752ec775c6553e Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Tue, 5 Dec 2023 16:38:46 +0100 Subject: [PATCH] Remove support for upgrade --- docs/guide/intro/index.adoc | 74 --- .../goals/AbstractBuildBootableJarMojo.java | 94 +--- .../bootablejar/maven/goals/MavenUpgrade.java | 453 ------------------ .../maven/goals/MavenUgradeTestCase.java | 171 ------- tests/pom.xml | 7 - .../AbstractBootableJarMojoTestCase.java | 9 - .../maven/goals/ChannelsTestCase.java | 21 - .../goals/UpgradeArtifactDumpTestCase.java | 51 -- .../UpgradeArtifactEE9TransformTestCase.java | 84 ---- .../goals/UpgradeArtifactFPLTestCase.java | 70 --- .../UpgradeArtifactInvalidFPTestCase.java | 43 -- .../goals/UpgradeArtifactInvalidTestCase.java | 43 -- .../goals/UpgradeArtifactSlimTestCase.java | 64 --- .../maven/goals/UpgradeArtifactTestCase.java | 122 ----- ...pgradeArtifactUnknownArtifactTestCase.java | 44 -- .../UpgradeArtifactVersOverrideTestCase.java | 84 ---- .../poms/invalid-fp-upgrade-artifact-pom.xml | 42 -- .../poms/invalid-upgrade-artifact-pom.xml | 35 -- .../invalid-upgrade-unknown-artifact-pom.xml | 40 -- .../poms/upgrade-artifact-dump-pom.xml | 43 -- .../poms/upgrade-artifact-ee9-pom.xml | 66 --- .../poms/upgrade-artifact-fpl-pom.xml | 43 -- .../resources/poms/upgrade-artifact-pom.xml | 66 --- .../poms/upgrade-artifact-slim-pom.xml | 58 --- .../upgrade-artifact-vers-override-pom.xml | 68 --- 25 files changed, 4 insertions(+), 1891 deletions(-) delete mode 100644 plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/MavenUpgrade.java delete mode 100644 plugin/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/MavenUgradeTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactDumpTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactEE9TransformTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactFPLTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactInvalidFPTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactInvalidTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactSlimTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactUnknownArtifactTestCase.java delete mode 100644 tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactVersOverrideTestCase.java delete mode 100644 tests/src/test/resources/poms/invalid-fp-upgrade-artifact-pom.xml delete mode 100644 tests/src/test/resources/poms/invalid-upgrade-artifact-pom.xml delete mode 100644 tests/src/test/resources/poms/invalid-upgrade-unknown-artifact-pom.xml delete mode 100644 tests/src/test/resources/poms/upgrade-artifact-dump-pom.xml delete mode 100644 tests/src/test/resources/poms/upgrade-artifact-ee9-pom.xml delete mode 100644 tests/src/test/resources/poms/upgrade-artifact-fpl-pom.xml delete mode 100644 tests/src/test/resources/poms/upgrade-artifact-pom.xml delete mode 100644 tests/src/test/resources/poms/upgrade-artifact-slim-pom.xml delete mode 100644 tests/src/test/resources/poms/upgrade-artifact-vers-override-pom.xml diff --git a/docs/guide/intro/index.adoc b/docs/guide/intro/index.adoc index 4d988dfb..80b942ac 100644 --- a/docs/guide/intro/index.adoc +++ b/docs/guide/intro/index.adoc @@ -563,80 +563,6 @@ It is possible to configure the plugin to use https://github.com/wildfly-extras/ ---- -[[wildfly_jar_advanced_upgrade]] -### Upgrading a bootable JAR - -This Feature is deprecated. It is going to be replaced by the usage of WildFly Channels. - -NB: This feature can't be used when WildFly Channels are configured. - -The artifacts referenced from JBoss Modules modules and Galleon feature-packs dependencies can be overridden when building a bootable JAR. This mechanism is based on Maven -dependencies resolution. - -The set of artifacts that can be upgraded can be retrieved by setting the parameter `true` or -the system property `bootable.jar.dump.original.artifacts` to true when building a bootable JAR. -The file `target/bootable-jar-build-artifacts/bootable-jar-server-original-artifacts.xml` is generated. -It contains XML elements for the Galleon feature-packs dependencies, JBoss Modules runtime and artifacts. -JBoss Modules modules artifacts are grouped by JBoss Modules name. -The generated file contains only the artifacts that are provisioned by Galleon. -Each artifact version is the one that would get installed when building the Bootable JAR without upgrade. - -The Maven artifacts to upgrade must be added to the `` of your Maven project (with a `provided` scope -to avoid the dependency to be added to your application). In addition, the plugin configuration element -`` must contain the artifacts. For example, the version 3.0.0 of `io.undertow:undertow-core` will -replace the version referenced in the WildFly Galleon feature-pack used to build the bootable JAR: - -[source,xml] ----- - - ... - - io.undertow - undertow-core - provided - 3.0.0 - - ... - - ... - - org.wildfly.plugins - wildfly-jar-maven-plugin - - - - io.undertow - undertow-core - - - ... ----- - -Some notes: - -* The server jar components that can be upgraded are: -** The JBoss module runtime jar (jboss-modules.jar file). -** All jar artifacts referenced from JBoss Modules modules. - -* If an overridden artifact is no present in the dependencies, then a failure occurs during build. - -* An artifact upgraded to the same version as the one referenced in the Galleon feature-pack is not upgraded. In this case a warning is displayed during build. - -* It is possible to downgrade an artifact to an older version. In this case a warning is displayed during build. - -* An artifact is referenced in the `overridden-server-artifacts` by GroupId, Artifactid and optionally Classifier. Version is being retrieved from the Maven dependencies if not set -in the overridden artifact. - -* An artifact presents in the `overridden-server-artifacts` list must be unique. Any duplicate will make the packaging to fail. - -* Adding an overridden artifact that is not part of the provisioned server artifacts will lead to a failure during build. - -* Adding an overridden Galleon feature-pack artifact that is not a dependency of the WildFly server being -provisioned will lead to an error during packaging. - -* Third party galleon feature-packs (eg: keycloak Galleon feature-pack) benefit from this upgrade capability -for JBoss Modules modules artifacts they are bringing to the provisioned server. - [[wildfly_jar_troubleshooting]] ## Troubleshooting diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBuildBootableJarMojo.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBuildBootableJarMojo.java index 324c308f..4e44fc8e 100644 --- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBuildBootableJarMojo.java +++ b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBuildBootableJarMojo.java @@ -101,7 +101,6 @@ import org.wildfly.plugins.bootablejar.maven.cli.RemoteCLIExecutor; import org.wildfly.plugins.bootablejar.maven.common.FeaturePack; import org.wildfly.plugins.bootablejar.maven.common.MavenRepositoriesEnricher; -import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact; import org.wildfly.plugins.bootablejar.maven.common.Utils; import org.wildfly.plugins.bootablejar.maven.common.Utils.ProvisioningSpecifics; import org.wildfly.security.manager.WildFlySecurityManager; @@ -316,49 +315,6 @@ public abstract class AbstractBuildBootableJarMojo extends AbstractMojo { @Parameter(alias = "bootable-jar-build-artifacts", property = "wildfly.bootable.jar.build.artifacts", defaultValue = "bootable-jar-build-artifacts") private String bootableJarBuildArtifacts; - /** - * Deprecated. A list of artifacts that override the one referenced in the WildFly - * Galleon feature-pack used to build the Bootable JAR. The artifacts - * present in this list must exist in the project dependencies (with a - * {@code provided} scope). GroupId and ArtifactId are mandatory. - * Classifier is required if non null. Version and Type are optional and are - * retrieved from the project dependencies. Dependencies on Galleon - * feature-pack can also be referenced from this list. {@code zip} type must be used for Galleon feature-packs. - * NB: This configuration item can't be used when Channels are in use.
- * Example of an override of the {@code io.undertow:undertow-core} - * artifact:
- * <overridden-server-artifacts>
- * <artifact>
- * <groupId>io.undertow</groupId>
- * <artifactId>undertow-core</artifactId>
- * </artifact>
- * </overridden-server-artifacts>
- */ - @Deprecated - @Parameter(alias = "overridden-server-artifacts") - List overriddenServerArtifacts = Collections.emptyList(); - - /** - * Deprecated. Set this parameter to true in order to retrieve the set of artifacts that can be upgraded. - * The file `target/bootable-jar-build-artifacts/bootable-jar-server-original-artifacts.xml` is generated. - * It contains XML elements for the Galleon feature-packs dependencies, JBoss Modules runtime and artifacts. - * JBoss Modules modules artifacts are grouped by JBoss Modules name. - * The generated file contains only the artifacts that are provisioned by Galleon. - * Each artifact version is the one that would get installed when building the Bootable JAR without upgrade. - */ - @Deprecated - @Parameter(alias = "dump-original-artifacts", property = "bootable.jar.dump.original.artifacts" , defaultValue = "false") - boolean dumpOriginalArtifacts; - - /** - * Deprecated. The plugin prints a warning when an overridden artifact is downgraded (updated to an older version). - * The version comparison is done based on Maven versioning. This warning can be disabled by setting this parameter to - * true. - */ - @Deprecated - @Parameter(alias = "disable-warn-for-artifact-downgrade", property = "bootable.jar.disable.warn.for.artifact.downgrade", defaultValue = "false") - boolean disableWarnForArtifactDowngrade; - /** * When calling mvn 'install', the bootable JAR artifact is attached to the project with the classifier 'bootable'. Use this parameter to * configure the classifier. @@ -1021,8 +977,6 @@ private void normalizeFeaturePackList() throws MojoExecutionException { if (featurePackLocation != null) { if (isChannelsProvisioning()) { featurePackLocation = formatLocation(featurePackLocation); - } else { - featurePackLocation = MavenUpgrade.locationWithVersion(featurePackLocation, artifactVersions); } featurePacks = new ArrayList<>(); FeaturePack fp = new FeaturePack(); @@ -1033,8 +987,6 @@ private void normalizeFeaturePackList() throws MojoExecutionException { if (fp.getLocation() != null) { if (isChannelsProvisioning()) { fp.setLocation(formatLocation(fp.getLocation())); - } else { - fp.setLocation(MavenUpgrade.locationWithVersion(fp.getLocation(), artifactVersions)); } } else { if (fp.getGroupId() == null || fp.getArtifactId() == null) { @@ -1122,21 +1074,6 @@ private Artifact provisionServer(Path home, Path outputProvisioningFile, Path wo ProvisioningConfig config = buildGalleonConfig(pm, defaultConfig).buildConfig(); IoUtils.recursiveDelete(home); getLog().info("Building server based on " + config.getFeaturePackDeps() + " galleon feature-packs"); - MavenUpgrade mavenUpgrade = null; - if (isChannelsProvisioning()) { - if (!overriddenServerArtifacts.isEmpty()) { - throw new MojoExecutionException("overridden-server-artifacts can't be configured when channels are configured."); - } - } else { - mavenUpgrade = new MavenUpgrade(this, config, pm); - // Dump artifacts - if (dumpOriginalArtifacts) { - Path file = workDir.resolve("bootable-jar-server-original-artifacts.xml"); - getLog().info("Dumping original Maven artifacts in " + file); - mavenUpgrade.dumpArtifacts(file); - } - config = mavenUpgrade.upgrade(); - } // store provisioning.xml try(FileWriter writer = new FileWriter(outputProvisioningFile.toFile())) { ProvisioningXmlWriter.getInstance().write(config, writer); @@ -1159,7 +1096,7 @@ private Artifact provisionServer(Path home, Path outputProvisioningFile, Path wo Artifact a = getArtifact(value); if ( BOOT_ARTIFACT_ID.equals(a.getArtifactId())) { // We got it. - getLog().info("Found boot artifact " + a + " in " + (mavenUpgrade == null ? fprt.getFPID() : mavenUpgrade.getMavenFeaturePack(fprt.getFPID()))); + getLog().info("Found boot artifact " + a + " in " + fprt.getFPID() ); bootArtifact = a; break; } @@ -1179,7 +1116,7 @@ private Artifact provisionServer(Path home, Path outputProvisioningFile, Path wo if ("wildfly-cli".equals(a.getArtifactId()) && "org.wildfly.core".equals(a.getGroupId())) { // We got it. - debug("Found cli artifact %s in %s", a, (mavenUpgrade == null ? fprt.getFPID() : mavenUpgrade.getMavenFeaturePack(fprt.getFPID()))); + debug("Found cli artifact %s in %s", a, fprt.getFPID()); cliArtifacts.add(new DefaultArtifact(a.getGroupId(), a.getArtifactId(), a.getVersion(), "provided", JAR, "client", new DefaultArtifactHandler(JAR))); continue; @@ -1262,17 +1199,6 @@ private static void zipServer(Path home, Path contentDir) throws IOException { zip(home, target); } - private OverriddenArtifact getOverriddenArtifact(String grpId, String artifactId) { - OverriddenArtifact ret = null; - for (OverriddenArtifact art : overriddenServerArtifacts) { - if(art.getGroupId().equals(grpId) && art.getArtifactId().equals(artifactId)) { - ret = art; - break; - } - } - return ret; - } - private void buildJar(Path contentDir, Path jarFile, Artifact artifact) throws MojoExecutionException, IOException { Path rtJarFile = resolveArtifact(artifact); // Check if that is an older server for which we can't upgrade the jboss-modules dependency. @@ -1280,20 +1206,8 @@ private void buildJar(Path contentDir, Path jarFile, Artifact artifact) throws M Path tmpDir = contentRoot.resolve("tmp_runtime"); Files.createDirectories(tmpDir); ZipUtils.unzip(rtJarFile, tmpDir); - OverriddenArtifact modules = getOverriddenArtifact(JBOSS_MODULES_GROUP_ID, JBOSS_MODULES_ARTIFACT_ID); - Path jbossModulesDependency = tmpDir.resolve("META-INF").resolve("maven").resolve(JBOSS_MODULES_GROUP_ID). - resolve(JBOSS_MODULES_ARTIFACT_ID).resolve("pom.xml"); - if (Files.exists(jbossModulesDependency)) { - if (modules != null) { - getLog().warn("Bootable JAR dependency on jboss-modules can't be upgraded, you must use a more recent version of the server."); - } - } else { - if (modules != null) { - jbossModules.setVersion(modules.getVersion()); - } - Path jbossModulesFile = resolveArtifact(jbossModules); - ZipUtils.unzip(jbossModulesFile, contentDir); - } + Path jbossModulesFile = resolveArtifact(jbossModules); + ZipUtils.unzip(jbossModulesFile, contentDir); ZipUtils.unzip(rtJarFile, contentDir); updateManifest(contentDir); zip(contentDir, jarFile); diff --git a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/MavenUpgrade.java b/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/MavenUpgrade.java deleted file mode 100644 index fb72d50f..00000000 --- a/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/MavenUpgrade.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.jboss.galleon.ProvisioningDescriptionException; -import org.jboss.galleon.ProvisioningException; -import org.jboss.galleon.ProvisioningManager; -import org.jboss.galleon.config.FeaturePackConfig; -import org.jboss.galleon.config.ProvisioningConfig; -import org.jboss.galleon.layout.FeaturePackDescriber; -import org.jboss.galleon.spec.FeaturePackSpec; -import org.jboss.galleon.universe.Channel; -import org.jboss.galleon.universe.FeaturePackLocation; -import org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec; -import org.jboss.galleon.universe.maven.MavenChannel; -import org.jboss.galleon.universe.maven.MavenUniverseException; -import org.wildfly.plugins.bootablejar.maven.common.FeaturePack; -import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact; - -final class MavenUpgrade { - - private final Map dependencies = new LinkedHashMap<>(); - private final Map topLevels = new LinkedHashMap<>(); - private final AbstractBuildBootableJarMojo mojo; - private final ProvisioningConfig config; - private final Map producerToGAC = new HashMap<>(); - private final ProvisioningManager pm; - private ScannedModules modules; - - MavenUpgrade(AbstractBuildBootableJarMojo mojo, ProvisioningConfig config, ProvisioningManager pm) - throws MavenUniverseException, ProvisioningException, MojoExecutionException { - this.mojo = mojo; - this.config = config; - this.pm = pm; - for (FeaturePackConfig cfg : config.getFeaturePackDeps()) { - FeaturePack fp = toFeaturePack(cfg, pm); - if (fp == null) { - throw new ProvisioningException("Invalid location " + cfg.getLocation()); - } - topLevels.put(fp.getGAC(), fp); - } - - // Resolve the FP to retrieve dependencies as expressed in fp spec. - Map resolvedFeaturePacks = new LinkedHashMap<>(); - for (FeaturePack fp : topLevels.values()) { - resolvedFeaturePacks.put(fp.getGAC(), mojo.resolveMaven(fp)); - } - mojo.debug("Top level feature-packs: %s", topLevels); - mojo.debug("Resolved feature-packs: %s", resolvedFeaturePacks); - for (Entry entry : resolvedFeaturePacks.entrySet()) { - FeaturePackSpec spec = FeaturePackDescriber.readSpec(entry.getValue()); - producerToGAC.put(spec.getFPID().getProducer(), entry.getKey()); - List allDeps = new ArrayList<>(); - for (FeaturePackConfig cfg : spec.getFeaturePackDeps()) { - allDeps.add(cfg); - } - for (FeaturePackConfig cfg : spec.getTransitiveDeps()) { - allDeps.add(cfg); - } - for (FeaturePackConfig cfg : allDeps) { - FeaturePack fp = toFeaturePack(cfg, pm); - if (fp != null) { - String gac = fp.getGAC(); - // Only add the dep if not already seen. The first installed FP dep wins. - if (!topLevels.containsKey(gac) && !dependencies.containsKey(gac)) { - // Resolve to retrieve the actual producer and map to GAC - Path p = mojo.resolveMaven(fp); - FeaturePackSpec depSpec = FeaturePackDescriber.readSpec(p); - producerToGAC.put(depSpec.getFPID().getProducer(), gac); - dependencies.put(gac, fp); - } - } - } - } - mojo.debug("FP dependencies %s", dependencies); - } - - private Map getOriginalVersions() throws ProvisioningException, MojoExecutionException { - return getScannedModules().getProvisionedArtifacts(); - } - - private ScannedModules getScannedModules() throws ProvisioningException, MojoExecutionException { - if (modules == null) { - modules = ScannedModules.scanProvisionedArtifacts(pm, config); - } - return modules; - } - - void dumpArtifacts(Path file) throws ProvisioningException, MojoExecutionException, IOException { - Map> perModules = getScannedModules().getPerModuleArtifacts(); - StringBuilder builder = new StringBuilder(); - builder.append("").append(System.lineSeparator()); - - // Add feature-pack dependencies - builder.append(" ").append(System.lineSeparator()); - for (FeaturePack fp : dependencies.values()) { - builder.append(" ").append(System.lineSeparator()); - builder.append(" ").append(fp.getGroupId()).append("").append(System.lineSeparator()); - builder.append(" ").append(fp.getArtifactId()).append("").append(System.lineSeparator()); - if (fp.getClassifier() != null && !fp.getClassifier().isEmpty()) { - builder.append(" ").append(fp.getClassifier()).append("").append(System.lineSeparator()); - } - builder.append(" ").append(fp.getVersion()).append("").append(System.lineSeparator()); - builder.append(" ").append(fp.getType()).append("").append(System.lineSeparator()); - builder.append(" ").append(System.lineSeparator()); - } - builder.append(" ").append(System.lineSeparator()); - builder.append(" ").append(System.lineSeparator()); - Artifact jbossModules = AbstractBuildBootableJarMojo.getArtifact(getScannedModules().getModuleRuntime()); - builder.append(" ").append(jbossModules.getGroupId()).append("").append(System.lineSeparator()); - builder.append(" ").append(jbossModules.getArtifactId()).append("").append(System.lineSeparator()); - if (jbossModules.getClassifier() != null && !jbossModules.getClassifier().isEmpty()) { - builder.append(" ").append(jbossModules.getClassifier()).append("").append(System.lineSeparator()); - } - builder.append(" ").append(jbossModules.getVersion()).append("").append(System.lineSeparator()); - builder.append(" ").append(jbossModules.getType()).append("").append(System.lineSeparator()); - builder.append(" ").append(System.lineSeparator()); - if (!getScannedModules().getCopiedArtifacts().isEmpty()) { - builder.append(" ").append(System.lineSeparator()); - for (String gav : getScannedModules().getCopiedArtifacts().values()) { - Artifact a = AbstractBuildBootableJarMojo.getArtifact(gav); - builder.append(" ").append(System.lineSeparator()); - builder.append(" ").append(a.getGroupId()).append("").append(System.lineSeparator()); - builder.append(" ").append(a.getArtifactId()).append("").append(System.lineSeparator()); - if (a.getClassifier() != null && !a.getClassifier().isEmpty()) { - builder.append(" ").append(a.getClassifier()).append("").append(System.lineSeparator()); - } - builder.append(" ").append(a.getVersion()).append("").append(System.lineSeparator()); - builder.append(" ").append(a.getType()).append("").append(System.lineSeparator()); - builder.append(" ").append(System.lineSeparator()); - } - builder.append(" ").append(System.lineSeparator()); - } - builder.append(" ").append(System.lineSeparator()); - for (Entry> module : perModules.entrySet()) { - builder.append(" ").append(System.lineSeparator()); - for (String s : module.getValue().values()) { - Artifact a = AbstractBuildBootableJarMojo.getArtifact(s); - builder.append(" ").append(System.lineSeparator()); - builder.append(" ").append(a.getGroupId()).append("").append(System.lineSeparator()); - builder.append(" ").append(a.getArtifactId()).append("").append(System.lineSeparator()); - if (a.getClassifier() != null && !a.getClassifier().isEmpty()) { - builder.append(" ").append(a.getClassifier()).append("").append(System.lineSeparator()); - } - builder.append(" ").append(a.getVersion()).append("").append(System.lineSeparator()); - builder.append(" ").append(a.getType()).append("").append(System.lineSeparator()); - builder.append(" ").append(System.lineSeparator()); - } - builder.append(" ").append(System.lineSeparator()); - } - builder.append(" ").append(System.lineSeparator()); - builder.append("").append(System.lineSeparator()); - Files.write(file, builder.toString().getBytes("UTF-8")); - } - - private static String getOriginalArtifactVersion(OverriddenArtifact a, Map originalArtifactVersions) { - StringBuilder keyBuilder = new StringBuilder(); - keyBuilder.append(a.getGroupId()).append(":").append(a.getArtifactId()); - if (a.getClassifier() != null && !a.getClassifier().isEmpty()) { - keyBuilder.append("::").append(a.getClassifier()); - } - String key = keyBuilder.toString(); - String value = originalArtifactVersions.get(key); - if (value == null) { - return null; - } - Artifact artifact = AbstractBuildBootableJarMojo.getArtifact(value); - return artifact.getVersion(); - } - - ProvisioningConfig upgrade() throws MojoExecutionException, ProvisioningDescriptionException, ProvisioningException { - if (mojo.overriddenServerArtifacts.isEmpty()) { - return config; - } - Map originalVersions = getOriginalVersions(); - List featurePackDependencies = new ArrayList<>(); - List artifactDependencies = new ArrayList<>(); - Map allArtifacts = new HashMap<>(); - for (OverriddenArtifact a : mojo.overriddenServerArtifacts) { - if (a.getGroupId() == null || a.getArtifactId() == null) { - throw new MojoExecutionException("Invalid overridden artifact " + a.getGAC() + ". GroupId and ArtifactId are required."); - } - String key = a.getGAC(); - if (allArtifacts.containsKey(key)) { - throw new MojoExecutionException("Artifact " + key + " is present more than once in the overridden artifacts. Must be unique."); - } else { - allArtifacts.put(key, a); - } - // Is it a potential feature-pack - if (dependencies.containsKey(key)) { - Artifact fpArtifact = mojo.artifactVersions.getFeaturePackArtifact(a.getGroupId(), a.getArtifactId(), a.getClassifier()); - if (fpArtifact == null) { - throw new MojoExecutionException("No version for Galleon feature-pack " + a.getGAC()); - } else { - checkScope(fpArtifact); - if (a.getVersion() != null) { - fpArtifact.setVersion(a.getVersion()); - } - FeaturePack dep = dependencies.get(key); - DefaultArtifactVersion orig = new DefaultArtifactVersion(dep.getVersion()); - DefaultArtifactVersion overriddenVersion = new DefaultArtifactVersion(fpArtifact.getVersion()); - int compared = orig.compareTo(overriddenVersion); - if (compared > 0) { - if (!mojo.disableWarnForArtifactDowngrade) { - mojo.getLog().warn("[UPDATE] Downgrading dependency " + key + " from " + dep.getVersion() + " to " + fpArtifact.getVersion()); - } - } else { - if (compared == 0) { - mojo.getLog().warn("[UPDATE] Dependency " + key + " will be not upgraded, already at version: " + fpArtifact.getVersion()); - } - } - if (compared != 0) { - FeaturePack fp = new FeaturePack(); - fp.setGroupId(a.getGroupId()); - fp.setArtifactId(a.getArtifactId()); - fp.setClassifier(fpArtifact.getClassifier()); - fp.setExtension(fpArtifact.getType()); - fp.setVersion(fpArtifact.getVersion()); - featurePackDependencies.add(fp); - } - } - } else { - Artifact mavenArtifact = mojo.artifactVersions.getArtifact(a); - if (mavenArtifact == null) { - // It could be a wrong FP not present in the list of dependencies - Artifact fpArtifact = mojo.artifactVersions.getFeaturePackArtifact(a.getGroupId(), a.getArtifactId(), a.getClassifier()); - if (fpArtifact != null) { - throw new MojoExecutionException("Zip artifact " + a.getGAC() + " not found in dependencies. " - + " Could be a wrong Galleon feature-pack used to override a feature-pack dependency."); - } - throw new MojoExecutionException("No version for artifact " + a.getGAC()); - } else { - checkScope(mavenArtifact); - if (a.getVersion() == null) { - a.setVersion(mavenArtifact.getVersion()); - } - if (a.getType() == null) { - a.setType(mavenArtifact.getType()); - } - String originalVersion = getOriginalArtifactVersion(a, originalVersions); - if (originalVersion == null) { - throw new MojoExecutionException("Overridden artifact " + a.getGAC() + " not know in provisioned feature-packs"); - } - DefaultArtifactVersion orig = new DefaultArtifactVersion(originalVersion); - DefaultArtifactVersion overriddenVersion = new DefaultArtifactVersion(a.getVersion()); - int compared = orig.compareTo(overriddenVersion); - if (compared > 0) { - if (!mojo.disableWarnForArtifactDowngrade) { - mojo.getLog().warn("[UPDATE] Downgrading artifact " + a.getGAC() + " from " + originalVersion + " to " + a.getVersion()); - } - } else { - if (compared == 0) { - mojo.getLog().warn("[UPDATE] Artifact " + a.getGAC() + " is already at version " + a.getVersion() + ", will be not upgraded."); - } - } - if (compared != 0) { - artifactDependencies.add(a); - } - } - } - } - if (!artifactDependencies.isEmpty() || !featurePackDependencies.isEmpty()) { - ProvisioningConfig.Builder c = ProvisioningConfig.builder(config); - if (!featurePackDependencies.isEmpty()) { - mojo.getLog().info("[UPDATE] Overriding Galleon feature-pack dependency with: "); - for (FeaturePack fp : featurePackDependencies) { - FeaturePackLocation fpl = FeaturePackLocation.fromString(fp.getMavenCoords()); - mojo.getLog().info("[UPDATE] " + fp.getGroupId() + ":" + fp.getArtifactId() + ":" - + (fp.getClassifier() == null ? "" : fp.getClassifier() + ":") - + fp.getVersion() + (fp.getExtension() == null ? "" : ":" + fp.getExtension())); - c.addTransitiveDep(fpl); - } - } - if (!artifactDependencies.isEmpty()) { - mojo.getLog().info("[UPDATE] Overriding server artifacts with:"); - if (!mojo.pluginOptions.containsKey("jboss-overridden-artifacts")) { - String updates = toOptionValue(artifactDependencies); - for (OverriddenArtifact update : artifactDependencies) { - mojo.getLog().info("[UPDATE] " + update.getGroupId() + ":" + update.getArtifactId() + ":" - + (update.getClassifier() == null ? "" : update.getClassifier() + ":") - + update.getVersion() + (update.getType() == null ? "" : ":" + update.getType())); - } - c.addOption("jboss-overridden-artifacts", updates); - } - } - return c.build(); - } else { - return config; - } - } - - void checkScope(Artifact a) { - if (!"provided".equals(a.getScope())) { - mojo.getLog().warn("[UPDATE] Overridden artifact " + a.getGroupId() +":"+ a.getArtifactId()+ - (a.getClassifier() == null ? "" : ":" + a.getClassifier()) + ":" + a.getVersion() + " is not of provided scope."); - } - } - - static String locationWithVersion(String featurePackLocation, MavenProjectArtifactVersions artifactVersions) throws MojoExecutionException { - FeaturePackLocation location = FeaturePackLocation.fromString(featurePackLocation); - if (location.getUniverse() == null || location.getUniverse().getLocation() == null) { - FeaturePack fp = getFeaturePack(featurePackLocation); - if (fp.getVersion() == null) { - Artifact fpArtifact = artifactVersions.getFeaturePackArtifact(fp.getGroupId(), fp.getArtifactId(), null); - if (fpArtifact == null) { - throw new MojoExecutionException("No version found for " + featurePackLocation); - } - fp.setVersion(fpArtifact.getVersion()); - featurePackLocation = fp.getMavenCoords(); - } - } - return featurePackLocation; - } - - private FeaturePack toFeaturePack(FeaturePackConfig cfg, ProvisioningManager pm) throws MojoExecutionException { - FeaturePack fp; - validateFPL(cfg.getLocation()); - if (cfg.getLocation().isMavenCoordinates()) { - fp = getFeaturePack(cfg.getLocation().toString()); - } else { - fp = getFeaturePack(cfg, pm); - } - return fp; - } - - private static void validateFPL(FeaturePackLocation fpl) throws MojoExecutionException { - if (fpl.getUniverse() == null || fpl.getProducer() == null) { - throw new MojoExecutionException("Invalid feature-pack location format: " + fpl); - } - } - - String getMavenFeaturePack(FeaturePackLocation.FPID location) { - String gac = producerToGAC.get(location.getProducer()); - if (gac == null) { - return location.toString(); - } else { - return gac + ":" + location.getBuild(); - } - } - - private FeaturePack getFeaturePack(FeaturePackConfig cfg, ProvisioningManager pm) { - try { - Channel channel = pm.getLayoutFactory().getUniverseResolver().getChannel(cfg.getLocation()); - if (channel instanceof MavenChannel) { - MavenChannel mavenChannel = (MavenChannel) channel; - FeaturePack fp = new FeaturePack(); - fp.setGroupId(mavenChannel.getFeaturePackGroupId()); - fp.setArtifactId(mavenChannel.getFeaturePackArtifactId()); - String build = cfg.getLocation().getBuild(); - if (build == null) { - build = mavenChannel.getLatestBuild(cfg.getLocation()); - } - fp.setVersion(build); - return fp; - } - } catch (ProvisioningException ex) { - // OK, invalid channel, can occurs for non registered FP that are referenced from GAV. - mojo.debug("Invalid channel for %s, the feature-pack is not known in the universe, skipping it.", cfg.getLocation()); - } - return null; - } - - //groupId:artifactid[:classfier:extension:][:version] - static FeaturePack getFeaturePack(String str) throws MojoExecutionException { - if (str == null) { - throw new MojoExecutionException("Null feature-pack coords"); - } - final String[] parts = str.split(":"); - if (parts.length < 2 || parts.length > 5) { - throw new MojoExecutionException("Invalid feature-pack location format: " + str); - } - FeaturePack fp = new FeaturePack(); - fp.setGroupId(parts[0]); - fp.setArtifactId(parts[1]); - String classifier; - String extension; - String version = null; - - if (parts.length >= 4) { - classifier = parts[2] == null || parts[2].isEmpty() ? null : parts[2]; - extension = parts[3] == null || parts[3].isEmpty() ? null : parts[3]; - fp.setClassifier(classifier); - if (extension != null) { - fp.setExtension(extension); - } - if (parts.length == 5) { - version = parts[4] == null || parts[4].isEmpty() ? null : parts[4]; - } - } else if (parts.length == 3) { - version = parts[2]; - } - - fp.setVersion(version); - return fp; - } - - static String toOptionValue(List lst) throws ProvisioningException { - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < lst.size(); i++) { - OverriddenArtifact artifact = lst.get(i); - validate(artifact); - builder.append(artifact.getGroupId()).append(":").append(artifact.getArtifactId()). - append(":").append(artifact.getVersion()).append(":"); - String classifier = artifact.getClassifier() == null ? "" : artifact.getClassifier(); - builder.append(classifier).append(":").append(artifact.getType()); - if (i < lst.size() - 1) { - builder.append("|"); - } - } - return builder.toString(); - } - - private static void validate(OverriddenArtifact artifact) throws ProvisioningException { - if (artifact.getGroupId() == null) { - throw new ProvisioningException("No groupId set for overridden artifact"); - } - if (artifact.getArtifactId() == null) { - throw new ProvisioningException("No artifactId set for overridden artifact"); - } - if (artifact.getVersion() == null) { - throw new ProvisioningException("No version set for overridden artifact"); - } - if (artifact.getType() == null) { - throw new ProvisioningException("No type set for overridden artifact"); - } - } -} diff --git a/plugin/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/MavenUgradeTestCase.java b/plugin/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/MavenUgradeTestCase.java deleted file mode 100644 index 4e01e472..00000000 --- a/plugin/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/MavenUgradeTestCase.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * - * Copyright 2021 Red Hat, Inc., and individual contributors - * as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import java.util.ArrayList; -import java.util.List; -import org.apache.maven.plugin.MojoExecutionException; -import org.jboss.galleon.ProvisioningException; - -import org.junit.Assert; -import org.junit.Test; -import org.wildfly.plugins.bootablejar.maven.common.FeaturePack; -import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact; - -public class MavenUgradeTestCase { - - @Test - public void testFeaturePack() throws Exception { - try { - MavenUpgrade.getFeaturePack(""); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX OK expected - } - try { - MavenUpgrade.getFeaturePack("foo"); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX OK expected - } - try { - MavenUpgrade.getFeaturePack("grp:art:class:ext:vers:foo"); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX OK expected - } - try { - MavenUpgrade.getFeaturePack(null); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX OK expected - } - String grpId = "grp"; - String artId = "art"; - String gac = grpId + ":" + artId; - FeaturePack fp = MavenUpgrade.getFeaturePack(gac); - Assert.assertEquals(grpId, fp.getGroupId()); - Assert.assertEquals(artId, fp.getArtifactId()); - Assert.assertEquals(gac, fp.getGAC()); - Assert.assertEquals(gac + "::zip", fp.getMavenCoords()); - - String version = "vers"; - String gav = gac + ":" + version; - fp = MavenUpgrade.getFeaturePack(gav); - Assert.assertEquals(grpId, fp.getGroupId()); - Assert.assertEquals(artId, fp.getArtifactId()); - Assert.assertEquals(version, fp.getVersion()); - Assert.assertEquals(gac, fp.getGAC()); - Assert.assertEquals(gac + "::zip:" + version, fp.getMavenCoords()); - - String classifier = "class"; - String extension = "ext"; - gac = gac + ":" + classifier; - String coords = gac + ":" + extension; - fp = MavenUpgrade.getFeaturePack(coords); - Assert.assertEquals(grpId, fp.getGroupId()); - Assert.assertEquals(artId, fp.getArtifactId()); - Assert.assertEquals(classifier, fp.getClassifier()); - Assert.assertEquals(extension, fp.getExtension()); - Assert.assertEquals(gac, fp.getGAC()); - Assert.assertEquals(coords, fp.getMavenCoords()); - - coords = coords + ":" + version; - fp = MavenUpgrade.getFeaturePack(coords); - Assert.assertEquals(grpId, fp.getGroupId()); - Assert.assertEquals(artId, fp.getArtifactId()); - Assert.assertEquals(classifier, fp.getClassifier()); - Assert.assertEquals(extension, fp.getExtension()); - Assert.assertEquals(version, fp.getVersion()); - Assert.assertEquals(gac, fp.getGAC()); - Assert.assertEquals(coords, fp.getMavenCoords()); - } - - @Test - public void testOptionValue() throws Exception { - List lst = new ArrayList<>(); - OverriddenArtifact art1 = new OverriddenArtifact(); - lst.add(art1); - try { - MavenUpgrade.toOptionValue(lst); - throw new Exception("Should have failed"); - } catch (ProvisioningException ex) { - // XXX ok expected - } - art1.setGroupId("foo"); - try { - MavenUpgrade.toOptionValue(lst); - throw new Exception("Should have failed"); - } catch (ProvisioningException ex) { - // XXX ok expected - } - art1.setArtifactId("bar"); - try { - MavenUpgrade.toOptionValue(lst); - throw new Exception("Should have failed"); - } catch (ProvisioningException ex) { - // XXX ok expected - } - - String gac = "foo:bar"; - Assert.assertEquals(art1.getGAC(), gac); - - art1.setVersion("vers"); - Assert.assertEquals(art1.getGAC(), gac); - - String expected = "foo:bar:vers::jar"; - String option = MavenUpgrade.toOptionValue(lst); - Assert.assertEquals(expected, option); - - art1.setType(null); - try { - MavenUpgrade.toOptionValue(lst); - throw new Exception("Should have failed"); - } catch (ProvisioningException ex) { - // XXX ok expected - } - - art1.setType("type"); - Assert.assertEquals(art1.getGAC(), gac); - expected = "foo:bar:vers::type"; - option = MavenUpgrade.toOptionValue(lst); - Assert.assertEquals(expected, option); - - art1.setClassifier("class"); - Assert.assertEquals(art1.getGAC(), gac + ":class"); - expected = "foo:bar:vers:class:type"; - - option = MavenUpgrade.toOptionValue(lst); - Assert.assertEquals(expected, option); - - OverriddenArtifact art2 = new OverriddenArtifact(); - art2.setGroupId("foo2"); - art2.setArtifactId("bar2"); - art2.setClassifier("class2"); - art2.setVersion("vers2"); - art2.setType("type2"); - - expected = expected + "|foo2:bar2:vers2:class2:type2"; - lst.add(art2); - - option = MavenUpgrade.toOptionValue(lst); - Assert.assertEquals(expected, option); - - } -} diff --git a/tests/pom.xml b/tests/pom.xml index 2f7dd715..55d3dc18 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -134,7 +134,6 @@ false ${surefire.redirect.to.file} - ${test.version.wildfly-ee.upgrade} ${test.version.wildfly} ${project.version} ${jbossas.dist} @@ -166,12 +165,6 @@ ${test.default.ee.cloud.config} ${test.patch.ee.product} - - - org.wildfly.plugins.bootablejar.maven.goals.UpgradeArtifactFPLTestCase.java - - org.wildfly.plugins.bootablejar.maven.goals.UpgradeArtifactTestCase.java - org.wildfly.plugins.bootablejar.maven.goals.DefaultCloudConfigurationExcludeLayerTestCase diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBootableJarMojoTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBootableJarMojoTestCase.java index 658446fc..a451962d 100644 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBootableJarMojoTestCase.java +++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBootableJarMojoTestCase.java @@ -66,14 +66,11 @@ public abstract class AbstractBootableJarMojoTestCase extends AbstractConfigured static final String WILDFLY_FPL = "test.fpl"; static final String WILDFLY_VERSION = "test.version.wildfly"; - static final String WILDFLY_EE_VERSION = "test.version.wildfly-ee.upgrade"; static final String WILDFLY_GROUP_ID = "test.groupid.wildfly"; static final String PLUGIN_VERSION = "test.plugin.version"; private static final String TEST_REPLACE = "TEST_REPLACE"; private static final String TEST_DEFAULT_CONFIG_REPLACE = "TEST_DEFAULT_CONFIG_REPLACE"; private static final String TEST_DEFAULT_CLOUD_CONFIG_REPLACE = "TEST_DEFAULT_CLOUD_CONFIG_REPLACE"; - private static final String TEST_REPLACE_WF_EE_VERSION = "WF_EE_VERSION"; - private static final String TEST_REPLACE_WF_GROUPID = "WF_GROUPID"; private static final String TEST_REPLACE_WF_VERSION = "WF_VERSION"; static final String PLUGIN_VERSION_TEST_REPLACE = "PLUGIN_VERSION"; static final String TEST_FILE = "test-" + AbstractBuildBootableJarMojo.BOOTABLE_SUFFIX + ".jar"; @@ -164,12 +161,6 @@ protected void patchPomFile(File pom) throws IOException { if (s.contains(TEST_REPLACE_WF_VERSION)) { s = s.replace(TEST_REPLACE_WF_VERSION, System.getProperty(WILDFLY_VERSION)); } - if (s.contains(TEST_REPLACE_WF_EE_VERSION)) { - s = s.replace(TEST_REPLACE_WF_EE_VERSION, System.getProperty(WILDFLY_EE_VERSION)); - } - if (s.contains(TEST_REPLACE_WF_GROUPID)) { - s = s.replace(TEST_REPLACE_WF_GROUPID, System.getProperty(WILDFLY_GROUP_ID)); - } if (s.contains(TEST_DEFAULT_CONFIG_REPLACE)) { s = s.replace(TEST_DEFAULT_CONFIG_REPLACE, System.getProperty(DEFAULT_CONFIG)); } diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelsTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelsTestCase.java index 3d77dc09..590ce3af 100644 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelsTestCase.java +++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/ChannelsTestCase.java @@ -22,9 +22,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import org.apache.maven.plugin.MojoExecutionException; import org.jboss.galleon.universe.maven.MavenArtifact; -import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact; import org.junit.Assert; import org.junit.Test; @@ -104,23 +102,4 @@ private void setupTestChannel(BuildBootableJarMojo mojo) throws IOException { config.setManifest(coordinate); mojo.channels.add(config); } - - @Test - public void testInvalidUpgrade() throws Exception { - BuildBootableJarMojo mojo = lookupMojo("package"); - setupTestChannel(mojo); - List artifacts = new ArrayList<>(); - OverriddenArtifact artifact = new OverriddenArtifact(); - artifact.setGroupId("com.foo"); - artifact.setArtifactId("bar"); - artifacts.add(artifact); - mojo.overriddenServerArtifacts = artifacts; - try { - mojo.execute(); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX Expected - Assert.assertTrue(ex.getLocalizedMessage(), ex.getLocalizedMessage().contains("overridden-server-artifacts can't be configured when channels are configured")); - } - } } diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactDumpTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactDumpTestCase.java deleted file mode 100644 index 49d961b8..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactDumpTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import java.nio.file.Files; -import java.nio.file.Path; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactDumpTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactDumpTestCase() { - super("upgrade-artifact-dump-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - BuildBootableJarMojo mojo = lookupMojo("package"); - mojo.recordState = true; - mojo.execute(); - final Path dir = getTestDir(); - String[] layers = {"jaxrs-server"}; - Path generatedFile = dir.resolve("target").resolve("bootable-jar-build-artifacts").resolve("bootable-jar-server-original-artifacts.xml"); - Assert.assertTrue(Files.exists(generatedFile)); - String str = new String(Files.readAllBytes(generatedFile), "UTF-8"); - Assert.assertTrue(str.contains("wildfly-ee-galleon-pack")); - Assert.assertTrue(str.contains("org.jboss.modules")); - Assert.assertTrue(str.contains("jboss-modules")); - Assert.assertTrue(str.contains("io.undertow")); - Assert.assertTrue(str.contains("undertow-core")); - checkJar(dir, true, true, layers, null, mojo.recordState); - } -} diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactEE9TransformTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactEE9TransformTestCase.java deleted file mode 100644 index f2e95d37..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactEE9TransformTestCase.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import java.nio.file.Files; -import java.nio.file.Path; -import org.apache.maven.artifact.Artifact; -import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact; - -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactEE9TransformTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactEE9TransformTestCase() { - super("upgrade-artifact-ee9-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - Assume.assumeFalse("Not stupported on XP", isXP()); - BuildBootableJarMojo mojo = lookupMojo("package"); - MavenProjectArtifactVersions artifacts = MavenProjectArtifactVersions.getInstance(mojo.project); - Assert.assertEquals(2, mojo.overriddenServerArtifacts.size()); - String undertowVersion = null; - String restEasySpringVersion = null; - boolean seenUndertow = false; - boolean seenRestEasy = false; - for (OverriddenArtifact oa : mojo.overriddenServerArtifacts) { - Artifact a = null; - if ("io.undertow".equals(oa.getGroupId())) { - a = artifacts.getArtifact(oa); - Assert.assertNotNull(oa.getGroupId() + ":" + oa.getArtifactId(), a); - seenUndertow = true; - undertowVersion = a.getVersion(); - } else if ("org.jboss.resteasy.spring".equals(oa.getGroupId())) { - a = artifacts.getArtifact(oa); - Assert.assertNotNull(oa.getGroupId() + ":" + oa.getArtifactId(), a); - seenRestEasy = true; - restEasySpringVersion = a.getVersion(); - } - Assert.assertNotNull(a); - Assert.assertNotNull(a.getVersion()); - Assert.assertEquals(oa.getGroupId(), a.getGroupId()); - Assert.assertEquals(oa.getArtifactId(), a.getArtifactId()); - } - Assert.assertTrue(seenUndertow && seenRestEasy); - mojo.recordState = true; - mojo.execute(); - final Path dir = getTestDir(); - String[] layers = {"jaxrs", "management"}; - Path unzippedJar = checkAndGetWildFlyHome(dir, true, true, layers, null, mojo.recordState); - try { - Path modulesDir = unzippedJar.resolve("modules").resolve("system").resolve("layers").resolve("base"); - Path undertow = modulesDir.resolve("io").resolve("undertow").resolve("core").resolve("main").resolve("undertow-core-" + undertowVersion + ".jar"); - Assert.assertTrue(undertow.toString(), Files.exists(undertow)); - Path resteasy = modulesDir.resolve("org").resolve("jboss").resolve("resteasy").resolve("resteasy-spring").resolve("main"). - resolve("bundled").resolve("resteasy-spring-jar").resolve("resteasy-spring-" + restEasySpringVersion + ".jar"); - Assert.assertTrue(resteasy.toString(), Files.exists(resteasy)); - } finally { - BuildBootableJarMojo.deleteDir(unzippedJar); - } - checkJar(dir, true, true, layers, null, mojo.recordState); - checkDeployment(dir, true); - } -} diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactFPLTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactFPLTestCase.java deleted file mode 100644 index b52fa6c9..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactFPLTestCase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import java.nio.file.Files; -import java.nio.file.Path; -import org.apache.maven.artifact.Artifact; -import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact; - -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactFPLTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactFPLTestCase() { - super("upgrade-artifact-fpl-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - Assume.assumeFalse("Not stupported on XP", isXP()); - BuildBootableJarMojo mojo = lookupMojo("package"); - MavenProjectArtifactVersions artifacts = MavenProjectArtifactVersions.getInstance(mojo.project); - // We have an older release of wildfly-ee-galleon-pack in the pom.xml - Assert.assertEquals(1, mojo.overriddenServerArtifacts.size()); - String wildflyeeVersion = null; - for (OverriddenArtifact oa : mojo.overriddenServerArtifacts) { - Artifact a = artifacts.getFeaturePackArtifact(oa.getGroupId(), oa.getArtifactId(), oa.getClassifier()); - Assert.assertNotNull(oa.getGroupId() + ":" + oa.getArtifactId(), a); - wildflyeeVersion = a.getVersion(); - - Assert.assertNotNull(a); - Assert.assertNotNull(a.getVersion()); - Assert.assertEquals(oa.getGroupId(), a.getGroupId()); - Assert.assertEquals(oa.getArtifactId(), a.getArtifactId()); - } - mojo.recordState = true; - mojo.execute(); - final Path dir = getTestDir(); - String[] layers = {"jaxrs-server"}; - Path unzippedJar = checkAndGetWildFlyHome(dir, true, true, layers, null, mojo.recordState); - try { - Path modulesDir = unzippedJar.resolve("modules").resolve("system").resolve("layers").resolve("base"); - Path ee = modulesDir.resolve("org").resolve("jboss").resolve("as").resolve("ee").resolve("main").resolve("wildfly-ee-jakarta-" + wildflyeeVersion + ".jar"); - Assert.assertTrue(ee.toString(), Files.exists(ee)); - } finally { - BuildBootableJarMojo.deleteDir(unzippedJar); - } - checkJar(dir, true, true, layers, null, mojo.recordState); - checkDeployment(dir, true); - } -} diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactInvalidFPTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactInvalidFPTestCase.java deleted file mode 100644 index a154ebf8..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactInvalidFPTestCase.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import org.apache.maven.plugin.MojoExecutionException; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactInvalidFPTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactInvalidFPTestCase() { - super("invalid-fp-upgrade-artifact-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - BuildBootableJarMojo mojo = lookupMojo("package"); - try { - mojo.execute(); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX OK, expected - Assert.assertTrue(ex.toString().contains("Zip artifact org.wildfly:wildfly-galleon-pack not found in dependencies")); - } - } -} diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactInvalidTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactInvalidTestCase.java deleted file mode 100644 index b04cc51e..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactInvalidTestCase.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import org.apache.maven.plugin.MojoExecutionException; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactInvalidTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactInvalidTestCase() { - super("invalid-upgrade-artifact-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - BuildBootableJarMojo mojo = lookupMojo("package"); - try { - mojo.execute(); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX OK, expected - Assert.assertTrue(ex.toString().contains("No version for artifact io.undertow:undertow-core")); - } - } -} diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactSlimTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactSlimTestCase.java deleted file mode 100644 index 22864203..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactSlimTestCase.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import java.nio.file.Files; -import java.nio.file.Path; - -import org.apache.maven.artifact.Artifact; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactSlimTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactSlimTestCase() { - super("upgrade-artifact-slim-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - BuildBootableJarMojo mojo = lookupMojo("package"); - MavenProjectArtifactVersions artifacts = MavenProjectArtifactVersions.getInstance(mojo.project); - // We have an older release of undertow-core in the pom.xml - Assert.assertEquals(1, mojo.overriddenServerArtifacts.size()); - Artifact a = artifacts.getArtifact(mojo.overriddenServerArtifacts.get(0)); - String undertowVersion = a.getVersion(); - Assert.assertNotNull(undertowVersion); - mojo.recordState = true; - mojo.execute(); - final Path dir = getTestDir(); - String[] layers = {"jaxrs-server"}; - Path unzippedJar = checkAndGetWildFlyHome(dir, true, true, layers, null, mojo.recordState); - try { - Path modulesDir = unzippedJar.resolve("modules").resolve("system").resolve("layers").resolve("base"); - Path module = modulesDir.resolve("io").resolve("undertow").resolve("core").resolve("main").resolve("module.xml"); - Assert.assertTrue(module.toString(), Files.exists(module)); - String moduleContent = new String(Files.readAllBytes(module), "UTF-8"); - Assert.assertTrue(moduleContent.contains("artifact name=\"io.undertow:undertow-core:"+undertowVersion+"\"")); - Path undertow = modulesDir.resolve("io").resolve("undertow").resolve("core").resolve("main").resolve("undertow-core-" + undertowVersion + ".jar"); - Assert.assertFalse(undertow.toString(), Files.exists(undertow)); - } finally { - BuildBootableJarMojo.deleteDir(unzippedJar); - } - checkJar(dir, true, true, layers, null, mojo.recordState); - checkDeployment(dir, true); - } -} diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactTestCase.java deleted file mode 100644 index 92ceb383..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactTestCase.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.MojoExecutionException; -import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact; - -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactTestCase() { - super("upgrade-artifact-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - Assume.assumeFalse("Not stupported on XP", isXP()); - BuildBootableJarMojo mojo = lookupMojo("package"); - MavenProjectArtifactVersions artifacts = MavenProjectArtifactVersions.getInstance(mojo.project); - // We have an older release of undertow-core and wildfly-ee-galleon-pack in the pom.xml - Assert.assertEquals(2, mojo.overriddenServerArtifacts.size()); - String undertowVersion = null; - String wildflyeeVersion = null; - boolean seenUndertow = false; - boolean seenFeaturePack = false; - for (OverriddenArtifact oa : mojo.overriddenServerArtifacts) { - Artifact a = null; - if ("io.undertow".equals(oa.getGroupId())) { - a = artifacts.getArtifact(oa); - Assert.assertNotNull(oa.getGroupId() + ":" + oa.getArtifactId(), a); - seenUndertow = true; - undertowVersion = a.getVersion(); - } else { - a = artifacts.getFeaturePackArtifact(oa.getGroupId(), oa.getArtifactId(), oa.getClassifier()); - Assert.assertNotNull(oa.getGroupId() + ":" + oa.getArtifactId(), a); - seenFeaturePack = true; - wildflyeeVersion = a.getVersion(); - } - Assert.assertNotNull(a); - Assert.assertNotNull(a.getVersion()); - Assert.assertEquals(oa.getGroupId(), a.getGroupId()); - Assert.assertEquals(oa.getArtifactId(), a.getArtifactId()); - } - Assert.assertTrue(seenUndertow && seenFeaturePack); - mojo.recordState = true; - mojo.execute(); - final Path dir = getTestDir(); - String[] layers = {"jaxrs-server"}; - Path unzippedJar = checkAndGetWildFlyHome(dir, true, true, layers, null, mojo.recordState); - try { - Path modulesDir = unzippedJar.resolve("modules").resolve("system").resolve("layers").resolve("base"); - Path undertow = modulesDir.resolve("io").resolve("undertow").resolve("core").resolve("main").resolve("undertow-core-" + undertowVersion + ".jar"); - Assert.assertTrue(undertow.toString(), Files.exists(undertow)); - Path ee = modulesDir.resolve("org").resolve("jboss").resolve("as").resolve("ee").resolve("main").resolve("wildfly-ee-jakarta-" + wildflyeeVersion + ".jar"); - Assert.assertTrue(ee.toString(), Files.exists(ee)); - Assert.assertTrue(ee.toString(), Files.exists(ee)); - } finally { - BuildBootableJarMojo.deleteDir(unzippedJar); - } - checkJar(dir, true, true, layers, null, mojo.recordState); - checkDeployment(dir, true); - } - - @Test - public void testInvalidUpgrades() throws Exception { - BuildBootableJarMojo mojo = lookupMojo("package"); - Assert.assertEquals(2, mojo.overriddenServerArtifacts.size()); - List orig = new ArrayList<>(); - orig.addAll(mojo.overriddenServerArtifacts); - mojo.overriddenServerArtifacts.addAll(mojo.overriddenServerArtifacts); - try { - mojo.execute(); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX Expected - } - mojo.overriddenServerArtifacts = orig; - String grpId = orig.get(0).getGroupId(); - try { - orig.get(0).getGroupId(); - orig.get(0).setGroupId(null); - mojo.execute(); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX Expected - } - orig.get(0).setGroupId(grpId); - try { - orig.get(1).setArtifactId(null); - mojo.execute(); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - // XXX Expected - } - - } -} diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactUnknownArtifactTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactUnknownArtifactTestCase.java deleted file mode 100644 index 46a58e7a..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactUnknownArtifactTestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import org.apache.maven.plugin.MojoExecutionException; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactUnknownArtifactTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactUnknownArtifactTestCase() { - super("invalid-upgrade-unknown-artifact-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - BuildBootableJarMojo mojo = lookupMojo("package"); - try { - mojo.execute(); - throw new Exception("Should have failed"); - } catch (MojoExecutionException ex) { - Assert.assertTrue(ex.toString().contains("Overridden artifact jakarta.platform:jakarta.jakartaee-api not know in provisioned feature-packs")); - // XXX OK, expected - } - } -} diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactVersOverrideTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactVersOverrideTestCase.java deleted file mode 100644 index c1f46086..00000000 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/UpgradeArtifactVersOverrideTestCase.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wildfly.plugins.bootablejar.maven.goals; - -import java.nio.file.Files; -import java.nio.file.Path; -import org.apache.maven.artifact.Artifact; -import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact; - -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; - -/** - * @author jdenise - */ -public class UpgradeArtifactVersOverrideTestCase extends AbstractBootableJarMojoTestCase { - - public UpgradeArtifactVersOverrideTestCase() { - super("upgrade-artifact-vers-override-pom.xml", true, null); - } - - @Test - public void testUpgrade() throws Exception { - Assume.assumeFalse("Not stupported on XP", isXP()); - BuildBootableJarMojo mojo = lookupMojo("package"); - MavenProjectArtifactVersions artifacts = MavenProjectArtifactVersions.getInstance(mojo.project); - // We have an older release of undertow-core and wildfly-ee-galleon-pack in the pom.xml - Assert.assertEquals(2, mojo.overriddenServerArtifacts.size()); - String undertowVersion = null; - String wildflyeeVersion = null; - boolean seenArtifact = false; - boolean seenFeaturePack = false; - for (OverriddenArtifact oa : mojo.overriddenServerArtifacts) { - Artifact a = null; - if ("io.undertow".equals(oa.getGroupId())) { - a = artifacts.getArtifact(oa); - Assert.assertNotNull(oa.getGroupId() + ":" + oa.getArtifactId(), a); - seenArtifact = true; - undertowVersion = oa.getVersion(); - } else { - a = artifacts.getFeaturePackArtifact(oa.getGroupId(), oa.getArtifactId(), oa.getClassifier()); - Assert.assertNotNull(oa.getGroupId() + ":" + oa.getArtifactId(), a); - seenFeaturePack = true; - wildflyeeVersion = oa.getVersion(); - } - Assert.assertNotNull(a); - Assert.assertNotNull(a.getVersion()); - Assert.assertEquals(oa.getGroupId(), a.getGroupId()); - Assert.assertEquals(oa.getArtifactId(), a.getArtifactId()); - } - Assert.assertTrue(seenArtifact && seenFeaturePack); - mojo.recordState = true; - mojo.execute(); - final Path dir = getTestDir(); - String[] layers = {"jaxrs-server"}; - Path unzippedJar = checkAndGetWildFlyHome(dir, true, true, layers, null, mojo.recordState); - try { - Path modulesDir = unzippedJar.resolve("modules").resolve("system").resolve("layers").resolve("base"); - Path undertow = modulesDir.resolve("io").resolve("undertow").resolve("core").resolve("main").resolve("undertow-core-" + undertowVersion + ".jar"); - Assert.assertTrue(undertow.toString(), Files.exists(undertow)); - Path ee = modulesDir.resolve("org").resolve("jboss").resolve("as").resolve("ee").resolve("main").resolve("wildfly-ee-" + wildflyeeVersion + ".jar"); - Assert.assertTrue(ee.toString(), Files.exists(ee)); - } finally { - BuildBootableJarMojo.deleteDir(unzippedJar); - } - checkJar(dir, true, true, layers, null, mojo.recordState); - checkDeployment(dir, true); - } -} diff --git a/tests/src/test/resources/poms/invalid-fp-upgrade-artifact-pom.xml b/tests/src/test/resources/poms/invalid-fp-upgrade-artifact-pom.xml deleted file mode 100644 index 78e2929e..00000000 --- a/tests/src/test/resources/poms/invalid-fp-upgrade-artifact-pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - org.wildfly - wildfly-galleon-pack - WF_VERSION - provided - zip - - - - test - - - wildfly-jar-maven-plugin - - TEST_REPLACE - - jaxrs - - - - org.wildfly - wildfly-galleon-pack - - - - - - - - diff --git a/tests/src/test/resources/poms/invalid-upgrade-artifact-pom.xml b/tests/src/test/resources/poms/invalid-upgrade-artifact-pom.xml deleted file mode 100644 index fba78ca8..00000000 --- a/tests/src/test/resources/poms/invalid-upgrade-artifact-pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - test - - - wildfly-jar-maven-plugin - - TEST_REPLACE - - jaxrs - - - - - io.undertow - undertow-core - - - - - - - - diff --git a/tests/src/test/resources/poms/invalid-upgrade-unknown-artifact-pom.xml b/tests/src/test/resources/poms/invalid-upgrade-unknown-artifact-pom.xml deleted file mode 100644 index 81554d02..00000000 --- a/tests/src/test/resources/poms/invalid-upgrade-unknown-artifact-pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - jakarta.platform - jakarta.jakartaee-api - 8.0.0 - provided - - - - test - - - wildfly-jar-maven-plugin - - TEST_REPLACE - - jaxrs - - - - jakarta.platform - jakarta.jakartaee-api - - - - - - - diff --git a/tests/src/test/resources/poms/upgrade-artifact-dump-pom.xml b/tests/src/test/resources/poms/upgrade-artifact-dump-pom.xml deleted file mode 100644 index 70ad324f..00000000 --- a/tests/src/test/resources/poms/upgrade-artifact-dump-pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - - WF_GROUPID - wildfly-galleon-pack - WF_VERSION - provided - zip - - - - test - - - wildfly-jar-maven-plugin - - true - - - WF_GROUPID - wildfly-galleon-pack - - - - jaxrs-server - - - - - - - diff --git a/tests/src/test/resources/poms/upgrade-artifact-ee9-pom.xml b/tests/src/test/resources/poms/upgrade-artifact-ee9-pom.xml deleted file mode 100644 index 8414f836..00000000 --- a/tests/src/test/resources/poms/upgrade-artifact-ee9-pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - - io.undertow - undertow-core - 2.2.2.Final - provided - - - WF_GROUPID - wildfly-preview-feature-pack - WF_VERSION - provided - zip - - - org.jboss.resteasy.spring - resteasy-spring - provided - 3.0.0.Alpha2 - - - - test - - - wildfly-jar-maven-plugin - - - - WF_GROUPID - wildfly-preview-feature-pack - - - - jaxrs - management - - - - - io.undertow - undertow-core - - - org.jboss.resteasy.spring - resteasy-spring - - - - - - - - diff --git a/tests/src/test/resources/poms/upgrade-artifact-fpl-pom.xml b/tests/src/test/resources/poms/upgrade-artifact-fpl-pom.xml deleted file mode 100644 index 1b43c948..00000000 --- a/tests/src/test/resources/poms/upgrade-artifact-fpl-pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - - WF_GROUPID - wildfly-ee-galleon-pack - WF_EE_VERSION - provided - zip - - - - test - - - wildfly-jar-maven-plugin - - TEST_REPLACE - - jaxrs-server - - - - WF_GROUPID - wildfly-ee-galleon-pack - - - - - - - - diff --git a/tests/src/test/resources/poms/upgrade-artifact-pom.xml b/tests/src/test/resources/poms/upgrade-artifact-pom.xml deleted file mode 100644 index ecfcc478..00000000 --- a/tests/src/test/resources/poms/upgrade-artifact-pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - - io.undertow - undertow-core - 2.2.2.Final - provided - - - WF_GROUPID - wildfly-galleon-pack - WF_VERSION - provided - zip - - - WF_GROUPID - wildfly-ee-galleon-pack - WF_EE_VERSION - provided - zip - - - - test - - - wildfly-jar-maven-plugin - - - - WF_GROUPID - wildfly-galleon-pack - - - - jaxrs-server - - - - - io.undertow - undertow-core - - - WF_GROUPID - wildfly-ee-galleon-pack - - - - - - - - diff --git a/tests/src/test/resources/poms/upgrade-artifact-slim-pom.xml b/tests/src/test/resources/poms/upgrade-artifact-slim-pom.xml deleted file mode 100644 index d87480b8..00000000 --- a/tests/src/test/resources/poms/upgrade-artifact-slim-pom.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - - io.undertow - undertow-core - 2.2.2.Final - provided - - - WF_GROUPID - wildfly-galleon-pack - WF_VERSION - provided - zip - - - - test - - - wildfly-jar-maven-plugin - - - - WF_GROUPID - wildfly-galleon-pack - - - - jaxrs-server - - - true - - - - - io.undertow - undertow-core - - - - - - - - diff --git a/tests/src/test/resources/poms/upgrade-artifact-vers-override-pom.xml b/tests/src/test/resources/poms/upgrade-artifact-vers-override-pom.xml deleted file mode 100644 index 0a252243..00000000 --- a/tests/src/test/resources/poms/upgrade-artifact-vers-override-pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - 4.0.0 - org.wildfly.plugins.tests - 1.0.0.Final-SNAPSHOT - test2 - war - - WildFly bootable jar Example for tests - - - - io.undertow - undertow-core - 2.2.2.Final - provided - - - WF_GROUPID - wildfly-galleon-pack - WF_VERSION - provided - zip - - - WF_GROUPID - wildfly-ee-galleon-pack - WF_EE_VERSION - provided - zip - - - - test - - - wildfly-jar-maven-plugin - - - - WF_GROUPID - wildfly-galleon-pack - - - - jaxrs-server - - - - - io.undertow - undertow-core - 2.2.3.Final - - - WF_GROUPID - wildfly-ee-galleon-pack - WF_VERSION - - - - - - - -