|
1 | 1 | package org.scm4j.releaser; |
2 | 2 |
|
3 | | -import java.io.File; |
4 | | -import java.util.ArrayList; |
5 | | -import java.util.List; |
6 | | -import java.util.function.Supplier; |
7 | | - |
8 | 3 | import org.scm4j.commons.progress.IProgress; |
9 | 4 | import org.scm4j.commons.progress.ProgressConsole; |
10 | 5 | import org.scm4j.releaser.actions.ActionKind; |
|
17 | 12 | import org.scm4j.releaser.scmactions.SCMActionRelease; |
18 | 13 | import org.scm4j.releaser.scmactions.SCMActionTag; |
19 | 14 |
|
| 15 | +import java.io.File; |
| 16 | +import java.util.ArrayList; |
| 17 | +import java.util.List; |
| 18 | +import java.util.function.Supplier; |
| 19 | + |
20 | 20 | public class SCMReleaser { |
21 | 21 |
|
22 | 22 | public static final String MDEPS_FILE_NAME = "mdeps"; |
@@ -53,47 +53,37 @@ public IAction getActionTree(Component comp, ActionKind actionKind, CalculatedRe |
53 | 53 | childActions.add(getActionTree(mdep, actionKind, calculatedResult)); |
54 | 54 | } |
55 | 55 |
|
56 | | - calculatedResult.setBuildStatus(comp, (Supplier<BuildStatus>) () -> { |
57 | | - return getBuildStatus(comp, calculatedResult, progress); |
58 | | - }); |
| 56 | + calculatedResult.setBuildStatus(comp, () -> getBuildStatus(comp, calculatedResult, progress)); |
59 | 57 |
|
60 | 58 | progress.close(); |
61 | 59 | return new SCMActionRelease(calculatedResult.getReleaseBranch(comp), comp, childActions, actionKind, calculatedResult.getBuildStatus(comp), calculatedResult); |
62 | 60 | } |
63 | 61 |
|
64 | 62 | protected BuildStatus getBuildStatus(Component comp, CalculatedResult calculatedResult, IProgress progress) { |
65 | 63 | Build mb = new Build(calculatedResult.getReleaseBranch(comp), comp, calculatedResult); |
66 | | - return reportDuration(() -> mb.getStatus(), "status calculation", comp, progress); |
| 64 | + return reportDuration(mb::getStatus, "status calculation", comp, progress); |
67 | 65 | } |
68 | 66 |
|
69 | | - private void calculateResultNoStatus(Component comp, CalculatedResult calculatedResult, IProgress progress) throws Exception { |
| 67 | + private void calculateResultNoStatus(Component comp, CalculatedResult calculatedResult, IProgress progress) { |
70 | 68 |
|
71 | 69 | if (Options.isPatch()) { |
72 | | - ReleaseBranch rb = calculatedResult.setReleaseBranch(comp, () -> { |
73 | | - return new ReleaseBranch(comp, comp.getCoords().getVersion()); |
74 | | - }); |
75 | | - calculatedResult.setMDeps(comp, () -> { |
76 | | - return rb.getMDeps(); |
77 | | - }); |
| 70 | + ReleaseBranch rb = calculatedResult.setReleaseBranch(comp, () -> new ReleaseBranch(comp, comp.getCoords().getVersion())); |
| 71 | + calculatedResult.setMDeps(comp, rb::getMDeps); |
78 | 72 | calculatedResult.setNeedsToFork(comp, () -> false); |
79 | 73 | return; |
80 | 74 | } |
81 | 75 |
|
82 | | - ReleaseBranch rb = calculatedResult.setReleaseBranch(comp, () -> { |
83 | | - return reportDuration(() -> new ReleaseBranch(comp), "release branch version calculation", comp, progress); |
84 | | - }); |
| 76 | + ReleaseBranch rb = calculatedResult.setReleaseBranch(comp, () -> reportDuration(() -> new ReleaseBranch(comp), "release branch version calculation", comp, progress)); |
85 | 77 | if (calculatedResult.getMDeps(comp) == null) { |
86 | 78 | boolean needToUseReleaseBranch = (comp.getVersion().isExact() || (!comp.getVersion().isExact() && !calculatedResult.setNeedsToFork(comp, () -> { |
87 | 79 | Build mb = new Build(rb, comp, calculatedResult); |
88 | | - return reportDuration(() -> mb.isNeedToFork(), "need to fork calculation", comp, progress); |
| 80 | + return reportDuration(mb::isNeedToFork, "need to fork calculation", comp, progress); |
89 | 81 | }))) && rb.exists(); |
90 | 82 | // untill has untilldb, ubl has untilldb. untill is BUILD_MDEPS, UBL has release branch but need to FORK. |
91 | 83 | // result: db for untill FORK, db for UBL is DONE prev version (mdep fro existing UBL RB is used) |
92 | 84 | // TODO: add test: untill build_mdeps, untill needs to be forked. UBL has release rbanch but has to be forked also. untilldbs must have the same status |
93 | | - calculatedResult.setMDeps(comp, () -> { |
94 | | - return reportDuration(() -> needToUseReleaseBranch ? rb.getMDeps() : new DevelopBranch(comp).getMDeps(), |
95 | | - String.format("read mdeps from %s branch", needToUseReleaseBranch ? "release" : "develop"), comp, progress); |
96 | | - }); |
| 85 | + calculatedResult.setMDeps(comp, () -> reportDuration(() -> needToUseReleaseBranch ? rb.getMDeps() : new DevelopBranch(comp).getMDeps(), |
| 86 | + String.format("read mdeps from %s branch", needToUseReleaseBranch ? "release" : "develop"), comp, progress)); |
97 | 87 | } |
98 | 88 | } |
99 | 89 |
|
|
0 commit comments