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

devonfw / IDEasy / 11560364436

28 Oct 2024 06:31PM UTC coverage: 66.705% (-0.04%) from 66.746%
11560364436

push

github

web-flow
#710: make workspace configuration robust (#719)

2406 of 3950 branches covered (60.91%)

Branch coverage included in aggregate %.

6275 of 9064 relevant lines covered (69.23%)

3.05 hits per line

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

40.0
cli/src/main/java/com/devonfw/tools/ide/merge/FileMerger.java
1
package com.devonfw.tools.ide.merge;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.nio.file.StandardCopyOption;
6

7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.environment.EnvironmentVariables;
9
import com.devonfw.tools.ide.variable.IdeVariables;
10

11
/**
12
 * {@link WorkspaceMerger} responsible for a single type of file.
13
 */
14
public abstract class FileMerger extends AbstractWorkspaceMerger {
15

16
  protected final boolean legacySupport;
17

18
  /**
19
   * The constructor.
20
   *
21
   * @param context the {@link #context}.
22
   */
23
  public FileMerger(IdeContext context) {
24

25
    super(context);
3✔
26
    this.legacySupport = IdeVariables.IDE_VARIABLE_SYNTAX_LEGACY_SUPPORT_ENABLED.get(context).booleanValue();
7✔
27
  }
1✔
28

29
  /**
30
   * @param sourceFile Path to source file.
31
   * @param targetFile Path to target file.
32
   */
33
  protected void copy(Path sourceFile, Path targetFile) {
34

35
    ensureParentDirectoryExists(targetFile);
×
36
    try {
37
      Files.copy(sourceFile, targetFile, StandardCopyOption.REPLACE_EXISTING);
×
38
    } catch (Exception e) {
×
39
      throw new IllegalStateException("Failed to copy file " + sourceFile + " to " + targetFile, e);
×
40
    }
×
41
  }
×
42

43
  @Override
44
  public final int merge(Path setup, Path update, EnvironmentVariables variables, Path workspace) {
45
    try {
46
      doMerge(setup, update, variables, workspace);
6✔
47
    } catch (Exception e) {
×
48
      this.context.error(e, "Failed to merge workspace file {}", workspace);
×
49
      return 1;
×
50
    }
1✔
51
    return 0;
2✔
52
  }
53

54
  /**
55
   * Same as {@link #merge(Path, Path, EnvironmentVariables, Path)} but without error handling.
56
   *
57
   * @param setup the setup {@link Path} for creation.
58
   * @param update the update {@link Path} for creation and update.
59
   * @param variables the {@link EnvironmentVariables} to {@link EnvironmentVariables#resolve(String, Object) resolve variables}.
60
   * @param workspace the workspace {@link Path} to create or update.
61
   */
62
  protected abstract void doMerge(Path setup, Path update, EnvironmentVariables variables, Path workspace);
63
}
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