Skip to content

Commit 39ceab2

Browse files
committed
Rename existing mojo "merge" to "redeploy"
And keep "merge" mojo (as defunct) for now. Fixes #13
1 parent 9bf7807 commit 39ceab2

File tree

2 files changed

+58
-11
lines changed

2 files changed

+58
-11
lines changed

plugin/src/main/java/eu/maveniverse/maven/njord/plugin3/MergeMojo.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package eu.maveniverse.maven.njord.plugin3;
22

3-
import eu.maveniverse.maven.njord.shared.impl.repository.ArtifactStoreDeployer;
43
import eu.maveniverse.maven.njord.shared.store.ArtifactStore;
54
import eu.maveniverse.maven.njord.shared.store.ArtifactStoreManager;
65
import java.io.IOException;
76
import java.util.Optional;
87
import org.apache.maven.plugins.annotations.Mojo;
98
import org.apache.maven.plugins.annotations.Parameter;
10-
import org.eclipse.aether.repository.RemoteRepository;
119

1210
/**
1311
* Merges {@code from} store onto {@code to} store, eventually dropping {@code from} store.
@@ -39,15 +37,11 @@ protected void doExecute(ArtifactStoreManager artifactStoreManager) throws IOExc
3937
logger.info("Merging {} -> {}", fromOptional.orElseThrow(), toOptional.orElseThrow());
4038
toOptional.orElseThrow().close();
4139
try (ArtifactStore from = fromOptional.orElseThrow()) {
42-
new ArtifactStoreDeployer(
43-
repositorySystem,
44-
mavenSession.getRepositorySession(),
45-
new RemoteRepository.Builder(to, "default", "njord:store:" + to).build())
46-
.deploy(from);
47-
if (drop) {
48-
logger.info("Dropping {}", from);
49-
artifactStoreManager.dropArtifactStore(from);
50-
}
40+
throw new RuntimeException("not implemented");
41+
// if (drop) {
42+
// logger.info("Dropping {}", from);
43+
// artifactStoreManager.dropArtifactStore(from);
44+
// }
5145
}
5246
}
5347
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package eu.maveniverse.maven.njord.plugin3;
2+
3+
import eu.maveniverse.maven.njord.shared.impl.repository.ArtifactStoreDeployer;
4+
import eu.maveniverse.maven.njord.shared.store.ArtifactStore;
5+
import eu.maveniverse.maven.njord.shared.store.ArtifactStoreManager;
6+
import java.io.IOException;
7+
import java.util.Optional;
8+
import org.apache.maven.plugins.annotations.Mojo;
9+
import org.apache.maven.plugins.annotations.Parameter;
10+
import org.eclipse.aether.repository.RemoteRepository;
11+
12+
/**
13+
* Redeploys {@code from} store onto {@code to} store, eventually dropping {@code from} store.
14+
*/
15+
@Mojo(name = "redeploy", threadSafe = true, requiresProject = false)
16+
public class RedeployMojo extends NjordMojoSupport {
17+
@Parameter(required = true, property = "from")
18+
private String from;
19+
20+
@Parameter(required = true, property = "to")
21+
private String to;
22+
23+
@Parameter(required = true, property = "drop", defaultValue = "true")
24+
private boolean drop;
25+
26+
@Override
27+
protected void doExecute(ArtifactStoreManager artifactStoreManager) throws IOException {
28+
Optional<ArtifactStore> fromOptional = artifactStoreManager.selectArtifactStore(from);
29+
Optional<ArtifactStore> toOptional = artifactStoreManager.selectArtifactStore(to);
30+
if (fromOptional.isEmpty()) {
31+
logger.warn("ArtifactStore with given name not found: {}", from);
32+
return;
33+
}
34+
if (toOptional.isEmpty()) {
35+
logger.warn("ArtifactStore with given name not found: {}", to);
36+
return;
37+
}
38+
39+
logger.info("Redeploying {} -> {}", fromOptional.orElseThrow(), toOptional.orElseThrow());
40+
toOptional.orElseThrow().close();
41+
try (ArtifactStore from = fromOptional.orElseThrow()) {
42+
new ArtifactStoreDeployer(
43+
repositorySystem,
44+
mavenSession.getRepositorySession(),
45+
new RemoteRepository.Builder(to, "default", "njord:store:" + to).build())
46+
.deploy(from);
47+
if (drop) {
48+
logger.info("Dropping {}", from);
49+
artifactStoreManager.dropArtifactStore(from);
50+
}
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)