View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * @deprecated
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  		// Might be skipping execution altogether
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 }