Skip to content

Commit bf241ba

Browse files
committed
deploymentUrl changed to deploymentPath:String
1 parent ad2b097 commit bf241ba

File tree

9 files changed

+39
-28
lines changed

9 files changed

+39
-28
lines changed

src/main/java/org/scm4j/deployer/api/Action.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class Action implements IAction {
99

1010
@Getter
11-
final private Class<? extends IComponentDeployer> installerClass;
11+
private final Class<? extends IComponentDeployer> installerClass;
1212
@Getter private Map<String, Object> params;
1313
private final Component comp;
1414

src/main/java/org/scm4j/deployer/api/Component.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public class Component implements IComponent {
1010

1111
@Getter
12-
final private Artifact artifactCoords;
12+
private final Artifact artifactCoords;
1313
@Getter
1414
private IDeploymentProcedure deploymentProcedure;
1515
private final ProductStructure ps;
@@ -36,4 +36,19 @@ public String toString() {
3636
"artifactCoords=" + artifactCoords +
3737
'}';
3838
}
39+
40+
@Override
41+
public boolean equals(Object o) {
42+
if (this == o) return true;
43+
if (o == null || getClass() != o.getClass()) return false;
44+
45+
Component component = (Component) o;
46+
47+
return artifactCoords.equals(component.artifactCoords);
48+
}
49+
50+
@Override
51+
public int hashCode() {
52+
return artifactCoords.hashCode();
53+
}
3954
}

src/main/java/org/scm4j/deployer/api/DeploymentContext.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import lombok.Data;
44

55
import java.io.File;
6-
import java.net.URL;
76
import java.util.Map;
87

98
@Data
109
public class DeploymentContext implements IDeploymentContext {
1110

12-
private String mainArtifact;
11+
private final String mainArtifact;
1312
private Map<String, File> artifacts;
14-
private URL deploymentURL;
13+
private String deploymentPath;
1514

1615
public DeploymentContext(String mainArtifact) {
1716
this.mainArtifact = mainArtifact;

src/main/java/org/scm4j/deployer/api/DeploymentProcedure.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
@Data
88
public class DeploymentProcedure implements IDeploymentProcedure {
99

10-
final private List<IComponentDeployer> componentDeployers;
10+
private final List<IComponentDeployer> componentDeployers;
1111

1212
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package org.scm4j.deployer.api;
22

3-
import java.net.URL;
4-
53
public interface IDeployedProduct extends IProduct {
64

7-
URL getDeploymentUrl();
5+
String getDeploymentPath();
86
String getProductVersion();
97

108
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package org.scm4j.deployer.api;
22

33
import java.io.File;
4-
import java.net.URL;
54
import java.util.Map;
65

76
public interface IDeploymentContext {
87

98
String getMainArtifact();
109
Map<String, File> getArtifacts();
11-
URL getDeploymentURL();
10+
11+
String getDeploymentPath();
1212

1313
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package org.scm4j.deployer.api;
22

3-
import java.net.URL;
43
import java.util.List;
54

65
public interface IProductStructure {
7-
URL getDefaultDeploymentURL();
6+
String getDefaultDeploymentPath();
87
List<IComponent> getComponents();
98
}

src/main/java/org/scm4j/deployer/api/ProductStructure.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,31 @@
22

33
import lombok.Getter;
44

5-
import java.net.MalformedURLException;
6-
import java.net.URL;
75
import java.util.ArrayList;
6+
import java.util.Collections;
87
import java.util.List;
98

109
public class ProductStructure implements IProductStructure {
1110

1211
@Getter
13-
private URL defaultDeploymentURL;
12+
private String defaultDeploymentPath;
1413
@Getter
1514
private List<IComponent> components;
1615

17-
private ProductStructure() {
16+
private ProductStructure(String defaultDeploymentPath) {
17+
this.defaultDeploymentPath = defaultDeploymentPath;
1818
}
1919

20-
public static ProductStructure create(String defaultDeploymentURL) {
21-
URL url;
22-
try {
23-
url = new URL(defaultDeploymentURL);
24-
} catch (MalformedURLException e) {
25-
throw new RuntimeException("Invalid URL: " + defaultDeploymentURL);
26-
}
27-
ProductStructure ps = new ProductStructure();
28-
ps.defaultDeploymentURL = url;
20+
public static ProductStructure create(String defaultDeploymentPath) {
21+
ProductStructure ps = new ProductStructure(defaultDeploymentPath);
2922
ps.components = new ArrayList<>();
3023
return ps;
3124
}
3225

3326
public static ProductStructure createEmptyStructure() {
34-
return new ProductStructure();
27+
ProductStructure ps = new ProductStructure("");
28+
ps.components = Collections.emptyList();
29+
return ps;
3530
}
3631

3732
public Component addComponent(String component) {

src/test/java/org/scm4j/deployer/api/ApiTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import org.junit.Test;
44

5+
import java.util.Collections;
6+
57
import static org.junit.Assert.assertEquals;
68
import static org.junit.Assert.assertNotNull;
79

@@ -40,9 +42,12 @@ public void init(IDeploymentContext depCtx) {
4042
.parent()
4143
.addComponent("345:345:345")
4244
.parent();
43-
assertEquals(ps.getDefaultDeploymentURL().toString(), "file:/C:/smth");
45+
assertEquals(ps.getDefaultDeploymentPath(), "file:/C:/smth");
4446
assertEquals(ps.getComponents().get(0).getArtifactCoords().toString(), "123:123:jar:123");
4547
assertEquals(ps.getComponents().get(1).getArtifactCoords().toString(), "345:345:jar:345");
4648
assertNotNull(ps.getComponents().get(0).getDeploymentProcedure().getComponentDeployers().get(0));
49+
ps = ProductStructure.createEmptyStructure();
50+
assertEquals(ps.getDefaultDeploymentPath(), "");
51+
assertEquals(ps.getComponents(), Collections.emptyList());
4752
}
4853
}

0 commit comments

Comments
 (0)