1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.execute;
17
18 import java.io.File;
19 import java.util.List;
20 import java.util.Properties;
21
22 import org.apache.commons.lang3.StringUtils;
23 import org.kuali.common.util.PropertyUtils;
24 import org.kuali.common.util.SimpleScanner;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.springframework.util.Assert;
28
29
30
31
32 @Deprecated
33 public class SetNexusRepositoryIdExecutable implements Executable {
34
35 private static final Logger logger = LoggerFactory.getLogger(SetNexusRepositoryIdExecutable.class);
36
37 Properties mavenProperties;
38 File buildDirectory;
39 boolean skip;
40
41 @Override
42 public void execute() {
43
44 if (skip) {
45 logger.info("Skipping execution");
46 return;
47 }
48
49 Assert.notNull(mavenProperties, "mavenProperties are null");
50 Assert.notNull(buildDirectory, "buildDirectory is null");
51 Assert.isTrue(buildDirectory.exists(), "buildDirectory does not exist");
52
53 File nexusDirectory = new File(buildDirectory, "nexus-staging");
54
55 SimpleScanner scanner = new SimpleScanner(nexusDirectory, "*.properties", null);
56 List<File> files = scanner.getFiles();
57
58 if (files.size() != 1) {
59 throw new IllegalStateException("There can be only one!");
60 }
61
62 File nexusPropertiesFile = files.get(0);
63
64 Properties nexusProperties = PropertyUtils.load(nexusPropertiesFile);
65
66 String value = nexusProperties.getProperty("stagingRepository.id");
67
68 if (StringUtils.isBlank(value)) {
69 throw new IllegalStateException("stagingRepository.id is blank");
70 }
71
72 mavenProperties.setProperty("nexus.stagingRepository.id", value);
73
74 }
75
76 public Properties getMavenProperties() {
77 return mavenProperties;
78 }
79
80 public void setMavenProperties(Properties mavenProperties) {
81 this.mavenProperties = mavenProperties;
82 }
83
84 public File getBuildDirectory() {
85 return buildDirectory;
86 }
87
88 public void setBuildDirectory(File buildDirectory) {
89 this.buildDirectory = buildDirectory;
90 }
91
92 public boolean isSkip() {
93 return skip;
94 }
95
96 public void setSkip(boolean skip) {
97 this.skip = skip;
98 }
99
100 }