Skip to content

Commit

Permalink
Merge pull request #320 from emmartins/CMTOOL-372
Browse files Browse the repository at this point in the history
[CMTOOL-372] skips migration of internal modules
  • Loading branch information
emmartins authored May 29, 2024
2 parents 8d4568f + 73a024c commit f80abde
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
17 changes: 17 additions & 0 deletions core/src/main/java/org/jboss/migration/core/jboss/JBossServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,14 @@ public static class Modules {
private final List<Path> addonDirs;
private final Path overlayDir;

private static final ModuleIdentifier[] INTERNAL_MODULES = {
ModuleIdentifier.fromString("java.desktop"),
ModuleIdentifier.fromString("java.logging"),
ModuleIdentifier.fromString("java.sql"),
ModuleIdentifier.fromString("java.xml"),
ModuleIdentifier.fromString("org.jboss.modules")
};

public Modules(Path serverBaseDir) {
this.modulesDir = serverBaseDir.resolve("modules");
this.layerDirs = new ArrayList<>();
Expand Down Expand Up @@ -459,6 +467,15 @@ public Path getModuleDir(ModuleIdentifier moduleId) {
}
return modulesDir.resolve(modulePath);
}

public boolean isInternalModule(ModuleIdentifier moduleIdentifier) {
for (ModuleIdentifier internalModuleIdentifier : INTERNAL_MODULES) {
if (internalModuleIdentifier.equals(moduleIdentifier)) {
return true;
}
}
return false;
}
}

public static class Extensions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,18 @@ public void migrateModule(final ModuleIdentifier moduleIdentifier, final String
context.getLogger().debugf("Skipping module %s migration, it's excluded by environment.", moduleIdentifier);
return;
}
final JBossServer.Module sourceModule = sourceModules.getModule(moduleIdentifier);
if (sourceModule == null) {
throw new IllegalStateException("Migration of module "+moduleIdentifier+" required, but module not found in source server.");
if (targetModules.isInternalModule(moduleIdentifier)) {
context.getLogger().debugf("Skipping module %s migration, it's an internal target server's module.", moduleIdentifier);
return;
}
if (targetModules.getModule(moduleIdentifier) != null) {
context.getLogger().debugf("Skipping module %s migration, already exists in target.", moduleIdentifier, reason);
return;
}
final JBossServer.Module sourceModule = sourceModules.getModule(moduleIdentifier);
if (sourceModule == null) {
throw new IllegalStateException("Migration of module "+moduleIdentifier+" required, but module not found in source server.");
}
final ServerMigrationTaskName taskName = new ServerMigrationTaskName.Builder(context.getTaskName().getName()+".migrate-module").addAttribute("id", moduleIdentifier.toString()).build();
final ServerMigrationTask subtask = new ServerMigrationTask() {
@Override
Expand Down
39 changes: 39 additions & 0 deletions testsuite/server-migration-simple-test-raw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
set -e
set -o pipefail

DIRNAME=`dirname "$0"`
TEST_DIR=`cd "$DIRNAME"; pwd`
TEST_BEFORE_DIR=$TEST_DIR/before/dist
TEST_AFTER_DIR=$TEST_DIR/after
TOOL_DIR="$TEST_DIR/jboss-server-migration"
SOURCE_DIST_DIR="$1"
TARGET_DIST_DIR="$2"

if [ "x$SOURCE_DIST_DIR" != "x" ]; then
if [[ $SOURCE_DIST_DIR != /* ]]; then
SOURCE_DIST_DIR="$TEST_DIR/$SOURCE_DIST_DIR"
fi
else
echo "### Usage: ./server-migration-simple-test.sh SOURCE_DIST_DIR TARGET_DIST_DIR"
exit
fi

if [ ! -d $SOURCE_DIST_DIR ]; then
echo "### Source Server base directory $SOURCE_DIST_DIR does not exists!"
exit 1;
fi
echo "### Source Server base directory: $SOURCE_DIST_DIR"

if [ ! -d $TARGET_DIST_DIR ]; then
echo "### Target Server dist directory $TARGET_DIST_DIR does not exists!"
exit 1;
fi
echo "### Target Server dist directory: $TARGET_DIST_DIR"

echo "### Preparing JBoss Server Migration Tool binary..."
rm -Rf $TOOL_DIR
unzip $TEST_DIR/../dist/standalone/target/jboss-server-migration-*.zip -d $TEST_DIR

echo "### Executing the migration..."
$TOOL_DIR/jboss-server-migration.sh -n -s $SOURCE_DIST_DIR -t $TARGET_DIST_DIR -Djboss.server.migration.modules.excludes=""

0 comments on commit f80abde

Please sign in to comment.