##// END OF EJS Templates
added setters to ContainerExtension
cin -
r6:c7ba4d8ec41a v1.1.1 default
parent child
Show More
@@ -1,2 +1,2
1 1 group=org.implab.gradle
2 version=1.1 No newline at end of file
2 version=1.1.1 No newline at end of file
@@ -1,94 +1,156
1 1 package org.implab.gradle.containers;
2 2
3 3 import java.util.Optional;
4 4
5 5 import org.gradle.api.Project;
6 import org.gradle.api.file.Directory;
6 7 import org.gradle.api.file.DirectoryProperty;
7 8 import org.gradle.api.file.ProjectLayout;
9 import org.gradle.api.file.RegularFile;
8 10 import org.gradle.api.file.RegularFileProperty;
9 11 import org.gradle.api.model.ObjectFactory;
10 12 import org.gradle.api.provider.Property;
11 13 import org.gradle.api.provider.Provider;
12 14
13 15 public class ContainerExtension {
14 16
15 17 private final Property<String> cliCmd;
16 18
17 19 private final Property<String> imageAuthority;
18 20
19 21 private final Property<String> imageGroup;
20 22
21 23 private final Property<String> imageShortName;
22 24
23 25 private final Property<String> imageTag;
24 26
25 27 private final Property<ImageName> imageName;
26 28
27 29 private final DirectoryProperty contextDir;
28 30
29 31 private final RegularFileProperty imageIdFile;
30 32
31 33 public ContainerExtension(ObjectFactory factory, ProjectLayout layout, Project project) {
32 34 contextDir = factory.directoryProperty();
33 35 contextDir.convention(layout.getBuildDirectory().dir("context"));
34 36
35 37 imageIdFile = factory.fileProperty();
36 38 imageIdFile.convention(layout.getBuildDirectory().file("imageId"));
37 39
38 40 cliCmd = factory.property(String.class);
39 41 cliCmd.set("docker");
40 42
41 43 imageAuthority = factory.property(String.class);
42 44 imageGroup = factory.property(String.class);
43 45 imageShortName = factory.property(String.class);
44 46
45 47 imageShortName.convention(project.getName());
46 48
47 49 imageTag = factory.property(String.class);
48 50 imageTag.set(project
49 51 .provider(() -> Optional.ofNullable(project.getVersion()).map(v -> v.toString()).orElse("latest")));
50 52
51 53 Provider<String> imageRepository = imageGroup.map(g -> g + "/" + imageShortName.get()).orElse(imageShortName);
52 54
53 55 imageName = factory.property(ImageName.class);
54 56 imageName.convention(project.provider(
55 57 () -> new ImageName().authority(imageAuthority.get()).name(imageRepository.get()).tag(imageTag.get())));
56 58 }
57 59
58 60 public Property<String> getCliCmd() {
59 61 return cliCmd;
60 62 }
61 63
62 64 public void setCliCmd(String cliCmd) {
63 65 this.cliCmd.set(cliCmd);
64 66 }
65 67
66 68 public DirectoryProperty getContextDirectory() {
67 69 return contextDir;
68 70 }
69 71
72 public void setContextDirectory(Directory dir) {
73 contextDir.set(dir);
74 }
75
76 public void setContextDirectory(Provider<Directory> dir) {
77 contextDir.set(dir);
78 }
79
70 80 public RegularFileProperty getImageIdFile() {
71 81 return imageIdFile;
72 82 }
73 83
84 public void setImageIdFile(RegularFile file) {
85 imageIdFile.set(file);
86 }
87
88 public void setImageIdFile(Provider<RegularFile> file) {
89 imageIdFile.set(file);
90 }
91
74 92 public Property<String> getImageAuthority() {
75 93 return imageAuthority;
76 94 }
77 95
96 public void setImageAuthority(String value) {
97 imageAuthority.set(value);
98 }
99
100 public void setImageAuthority(Provider<String> value) {
101 imageAuthority.set(value);
102 }
103
78 104 public Property<String> getImageGroup() {
79 105 return imageGroup;
80 106 }
81 107
108 public void setImageGroup(String value) {
109 imageGroup.set(value);
110 }
111
112 public void setImageGroup(Provider<String> value) {
113 imageGroup.set(value);
114 }
115
82 116 public Property<ImageName> getImageName() {
83 117 return imageName;
84 118 }
85 119
120 public void setImageName(ImageName name) {
121 imageName.set(name);
122 }
123
124 public void setImageName(Provider<ImageName> name) {
125 imageName.set(name);
126 }
127
86 128 public Property<String> getImageShortName() {
87 129 return imageShortName;
88 130 }
89 131
132 public void setImageShortName(String name) {
133 imageShortName.set(name);
134 }
135
136 public void setImageShortName(Provider<String> name) {
137 imageShortName.set(name);
138 }
139
140 public Property<String> getImageTag() {
141 return imageTag;
142 }
143
144 public void setImageTag(String tag) {
145 imageTag.set(tag);
146 }
147
148 public void setImageTag(Provider<String> tag) {
149 imageTag.set(tag);
150 }
151
90 152 public ImageName createImageName() {
91 153 return new ImageName();
92 154 }
93 155
94 156 } No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now