• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 18131766199

30 Sep 2025 01:35PM UTC coverage: 68.475% (+0.01%) from 68.465%
18131766199

Pull #1507

github

web-flow
Merge 1b89cf9ad into 3602dff9e
Pull Request #1507: #1506: added migration

3439 of 5501 branches covered (62.52%)

Branch coverage included in aggregate %.

8996 of 12659 relevant lines covered (71.06%)

3.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.66
cli/src/main/java/com/devonfw/tools/ide/migration/IdeMigrator.java
1
package com.devonfw.tools.ide.migration;
2

3
import java.util.List;
4

5
import com.devonfw.tools.ide.context.IdeContext;
6
import com.devonfw.tools.ide.migration.v2025.Mig202502001;
7
import com.devonfw.tools.ide.migration.v2025.Mig202509001;
8
import com.devonfw.tools.ide.step.Step;
9
import com.devonfw.tools.ide.version.IdeVersion;
10
import com.devonfw.tools.ide.version.VersionIdentifier;
11

12
/**
13
 * The entry point to {@link IdeMigration} that orchestrates all {@link IdeVersionMigration}s.
14
 */
15
public class IdeMigrator implements IdeMigration {
16

17
  /** {@link VersionIdentifier} to use as fallback if {@link IdeContext#FILE_SOFTWARE_VERSION} does not exist. */
18
  public static final VersionIdentifier START_VERSION = VersionIdentifier.of("2025.01.001-beta");
4✔
19

20
  private final List<IdeVersionMigration> migrations;
21

22
  /**
23
   * The default constructor.
24
   */
25
  public IdeMigrator() {
26

27
    // migrations must be strictly in ascending order (from oldest to newest version)
28
    this(List.of(new Mig202502001(), new Mig202509001()));
9✔
29
  }
1✔
30

31
  /**
32
   * @param migrations the {@link List} of {@link IdeVersionMigration}s.
33
   */
34
  public IdeMigrator(List<IdeVersionMigration> migrations) {
35

36
    super();
2✔
37
    this.migrations = migrations;
3✔
38
  }
1✔
39

40
  @Override
41
  public VersionIdentifier getTargetVersion() {
42

43
    int size = this.migrations.size();
4✔
44
    int last = size - 1;
4✔
45
    if (last >= 0) {
2!
46
      return this.migrations.get(last).getTargetVersion();
7✔
47
    }
48
    // fallback that should never happen
49
    return IdeVersion.getVersionIdentifier();
×
50
  }
51

52
  @Override
53
  public void run(IdeContext context) {
54

55
    if (context.getIdeHome() == null) {
3✔
56
      context.debug("Skipping migration since IDE_HOME is undefined.");
3✔
57
      return;
1✔
58
    }
59
    VersionIdentifier currentVersion = context.getProjectVersion();
3✔
60
    VersionIdentifier previousTarget = null;
2✔
61
    int migrationCount = 0;
2✔
62
    for (IdeVersionMigration migration : this.migrations) {
11✔
63
      VersionIdentifier targetVersion = migration.getTargetVersion();
3✔
64
      if (previousTarget != null) {
2✔
65
        if (!targetVersion.isGreater(previousTarget)) {
4!
66
          throw new IllegalStateException("Invalid migration order with " + targetVersion + " after " + previousTarget);
×
67
        }
68
      }
69
      previousTarget = targetVersion;
2✔
70
      if ((migrationCount > 0) || currentVersion.isLess(targetVersion)) {
6✔
71
        Step step = context.newStep("Migrate IDEasy project from " + currentVersion + " to " + targetVersion);
8✔
72
        boolean success = step.run(() -> {
6✔
73
          migration.run(context);
3✔
74
        });
1✔
75
        if (success) {
2!
76
          context.setProjectVersion(targetVersion);
3✔
77
          currentVersion = targetVersion;
2✔
78
          migrationCount++;
2✔
79
        } else {
80
          throw new IllegalStateException("Failed: " + step.getName());
×
81
        }
82
      } else {
1✔
83
        context.debug("Skipping migration {} since we are already at version {}", targetVersion, currentVersion);
13✔
84
      }
85
    }
1✔
86
    if (migrationCount > 0) {
2✔
87
      context.success("Successfully applied {} migration(s) to project {}", migrationCount, context.getProjectName());
16✔
88
    } else {
89
      context.debug("No migration to apply to project {}", context.getProjectName());
10✔
90
    }
91
  }
1✔
92
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc