Skip to content

Commit 901ace5

Browse files
author
Jay Denebeim
committed
Back out BI-181 changes
1 parent 43275d8 commit 901ace5

File tree

12 files changed

+58
-85
lines changed

12 files changed

+58
-85
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
build-info.ipr
1515
build-info.iws
1616
atlassian-*.xml
17-
/.nb-gradle/private/

build-info-api/src/main/java/org/jfrog/build/api/BuildInfoConfigProperties.java

-5
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,4 @@ public interface BuildInfoConfigProperties {
4141

4242
String ENV_VARS_EXCLUDE_PATTERNS = "envVarsExcludePatterns";
4343
String PROP_ENV_VARS_EXCLUDE_PATTERNS = BUILD_INFO_CONFIG_PREFIX + ENV_VARS_EXCLUDE_PATTERNS;
44-
45-
/**
46-
* Secondary environment variable to hold the properties file name
47-
*/
48-
String ENV_BUILDINFO_PROPFILE = "BUILDINFO_PROPFILE";
4944
}

build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java

-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ public Map<String, String> getAllRootConfig() {
9292
return rootConfig.props;
9393
}
9494

95-
public Log getLog() {
96-
return root.getLog();
97-
}
98-
9995
public void persistToPropertiesFile() {
10096
if (StringUtils.isEmpty(getPropertiesFile())) {
10197
return;

build-info-client/src/main/java/org/jfrog/build/client/PrefixPropertyHandler.java

-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ private PrefixPropertyHandler(Log log, Map<String, String> props, String prefix)
2828
this.prefix = prefix;
2929
}
3030

31-
public Log getLog() {
32-
return log;
33-
}
34-
3531
public String getPrefix() {
3632
return prefix;
3733
}

build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/extractor/GradleArtifactoryClientConfigUpdater.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.jfrog.gradle.plugin.artifactory.extractor;
1818

19+
import com.google.common.base.Predicate;
20+
import com.google.common.collect.Maps;
1921
import org.apache.commons.lang.StringUtils;
2022
import org.gradle.StartParameter;
2123
import org.gradle.api.Project;
@@ -24,6 +26,7 @@
2426
import org.jfrog.build.client.ArtifactoryClientConfiguration;
2527
import org.jfrog.build.extractor.BuildInfoExtractorUtils;
2628

29+
import javax.annotation.Nullable;
2730
import java.text.ParseException;
2831
import java.text.SimpleDateFormat;
2932
import java.util.Date;
@@ -61,7 +64,7 @@ public static void update(ArtifactoryClientConfiguration config, Project project
6164
props.putAll(BuildInfoExtractorUtils.filterStringEntries(startProps));
6265

6366
// Then System properties
64-
Properties mergedProps = BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(props, config.info.getLog());
67+
Properties mergedProps = BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(props);
6568
// Then special buildInfo properties
6669
Properties buildInfoProperties =
6770
BuildInfoExtractorUtils.filterDynamicProperties(mergedProps, BUILD_INFO_PROP_PREDICATE);

build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/extractor/GradleBuildInfoExtractor.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public Build extract(Project rootProject) {
216216
if (clientConf.isIncludeEnvVars()) {
217217
Properties envProperties = new Properties();
218218
envProperties.putAll(clientConf.getAllProperties());
219-
envProperties = BuildInfoExtractorUtils.getEnvProperties(envProperties, clientConf.getLog());
219+
envProperties = BuildInfoExtractorUtils.getEnvProperties(envProperties);
220220
for (Map.Entry<Object, Object> envProp : envProperties.entrySet()) {
221221
bib.addProperty(envProp.getKey(), envProp.getValue());
222222
}
@@ -291,7 +291,6 @@ public Artifact apply(GradleDeployDetails from) {
291291
}));
292292
return artifacts;
293293
}
294-
295294
private List<Dependency> calculateDependencies(Project project) throws Exception {
296295
Set<Configuration> configurationSet = project.getConfigurations();
297296
List<Dependency> dependencies = newArrayList();
@@ -361,10 +360,10 @@ public IncludeExcludePredicate(Project project, IncludeExcludePatterns patterns,
361360
}
362361

363362
public boolean apply(@Nullable GradleDeployDetails input) {
364-
if (include) {
363+
if(include){
365364
return input.getProject().equals(project) && !PatternMatcher.pathConflicts(input.getDeployDetails().getArtifactPath(), patterns);
366-
} else {
367-
return input.getProject().equals(project) && PatternMatcher.pathConflicts(input.getDeployDetails().getArtifactPath(), patterns);
365+
}else{
366+
return input.getProject().equals(project) && PatternMatcher.pathConflicts(input.getDeployDetails().getArtifactPath(), patterns);
368367
}
369368
}
370369
}

build-info-extractor-ivy/src/main/java/org/jfrog/build/extractor/listener/ArtifactoryBuildListener.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private void assertInitialized(BuildEvent event) {
6464
private Properties getMergedEnvAndSystemProps() {
6565
Properties props = new Properties();
6666
props.putAll(System.getenv());
67-
return BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(props, buildInfoLog);
67+
return BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(props);
6868
}
6969

7070
public IvyBuildInfoLog getBuildInfoLog(BuildEvent event) {
@@ -327,7 +327,7 @@ private void doDeploy(BuildEvent event) {
327327
if (clientConf.isIncludeEnvVars()) {
328328
Properties envProperties = new Properties();
329329
envProperties.putAll(clientConf.getAllProperties());
330-
envProperties = BuildInfoExtractorUtils.getEnvProperties(envProperties, clientConf.getLog());
330+
envProperties = BuildInfoExtractorUtils.getEnvProperties(envProperties);
331331
for (Map.Entry<Object, Object> envProp : envProperties.entrySet()) {
332332
builder.addProperty(envProp.getKey(), envProp.getValue());
333333
}

build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/BuildInfoRecorder.java

+21-15
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public void projectDiscoveryStarted(ExecutionEvent event) {
103103

104104
@Override
105105
public void sessionStarted(ExecutionEvent event) {
106-
try {
106+
try
107+
{
107108
logger.info("Initializing Artifactory Build-Info Recording");
108109
buildInfoBuilder = buildInfoModelPropertyResolver.resolveProperties(event, conf);
109110
deployableArtifactBuilderMap = Maps.newHashMap();
@@ -118,10 +119,12 @@ public void sessionStarted(ExecutionEvent event) {
118119
if (wrappedListener != null) {
119120
wrappedListener.sessionStarted(event);
120121
}
121-
} catch (Throwable t) {
122+
}
123+
catch ( Throwable t )
124+
{
122125
String message = getClass().getName() + ".sessionStarted() listener has failed: ";
123-
logger.error(message, t);
124-
throw new RuntimeException(message, t);
126+
logger.error( message, t );
127+
throw new RuntimeException( message, t );
125128
}
126129
}
127130

@@ -132,17 +135,20 @@ public void sessionEnded(ExecutionEvent event) {
132135
if (build != null) {
133136
File basedir = event.getSession().getTopLevelProject().getBasedir();
134137
conf.persistToPropertiesFile();
135-
buildDeploymentHelper.deploy(build, conf, deployableArtifactBuilderMap, projectHasTestFailures, basedir);
138+
buildDeploymentHelper.deploy(build, conf, deployableArtifactBuilderMap, projectHasTestFailures,basedir);
136139
}
137140
deployableArtifactBuilderMap.clear();
138141
if (wrappedListener != null) {
139142
wrappedListener.sessionEnded(event);
140143
}
141-
} catch (Throwable t) {
144+
}
145+
catch ( Throwable t )
146+
{
142147
String message = getClass().getName() + ".sessionEnded() listener has failed: ";
143-
logger.error(message, t);
144-
throw new RuntimeException(message, t);
145-
} finally {
148+
logger.error( message, t );
149+
throw new RuntimeException( message, t );
150+
}
151+
finally {
146152
String propertyFilePath = System.getenv(BuildInfoConfigProperties.PROP_PROPS_FILE);
147153
if (StringUtils.isNotBlank(propertyFilePath)) {
148154
File file = new File(propertyFilePath);
@@ -448,9 +454,9 @@ private void addArtifactsToCurrentModule(MavenProject project, ModuleBuilder mod
448454
String groupId = moduleArtifact.getGroupId();
449455
String deploymentPath = getDeploymentPath(groupId, artifactId, artifactVersion, artifactClassifier, artifactExtension);
450456
// If excludeArtifactsFromBuild and the PatternMatcher found conflict, add the excluded artifact to the excluded artifact set.
451-
if (excludeArtifactsFromBuild && PatternMatcher.pathConflicts(deploymentPath, patterns)) {
457+
if(excludeArtifactsFromBuild && PatternMatcher.pathConflicts(deploymentPath,patterns)){
452458
module.addExcludedArtifact(artifact);
453-
} else {
459+
}else{
454460
module.addArtifact(artifact);
455461
}
456462
if (isPublishArtifacts(artifactFile)) {
@@ -470,9 +476,9 @@ private void addArtifactsToCurrentModule(MavenProject project, ModuleBuilder mod
470476
artifactBuilder.name(pomFileName);
471477
org.jfrog.build.api.Artifact pomArtifact = artifactBuilder.build();
472478
deploymentPath = getDeploymentPath(groupId, artifactId, artifactVersion, artifactClassifier, "pom");
473-
if (excludeArtifactsFromBuild && PatternMatcher.pathConflicts(deploymentPath, patterns)) {
479+
if(excludeArtifactsFromBuild && PatternMatcher.pathConflicts(deploymentPath,patterns)){
474480
module.addExcludedArtifact(pomArtifact);
475-
} else {
481+
}else{
476482
module.addArtifact(pomArtifact);
477483
}
478484
if (isPublishArtifacts(pomFile)) {
@@ -522,7 +528,7 @@ private void addDeployableArtifact(org.jfrog.build.api.Artifact artifact, File a
522528
/**
523529
* @param deployPath the full path string to extract the repo from
524530
* @return Return the target deployment repository. Either the releases repository (default) or snapshots if defined
525-
* and the deployed file is a snapshot.
531+
* and the deployed file is a snapshot.
526532
*/
527533
public String getTargetRepository(String deployPath) {
528534
String snapshotsRepository = conf.publisher.getSnapshotRepoKey();
@@ -598,7 +604,7 @@ public Build extract(ExecutionEvent event) {
598604
if (conf.isIncludeEnvVars()) {
599605
Properties envProperties = new Properties();
600606
envProperties.putAll(conf.getAllProperties());
601-
envProperties = BuildInfoExtractorUtils.getEnvProperties(envProperties, conf.getLog());
607+
envProperties = BuildInfoExtractorUtils.getEnvProperties(envProperties);
602608
for (Map.Entry<Object, Object> envProp : envProperties.entrySet()) {
603609
buildInfoBuilder.addProperty(envProp.getKey(), envProp.getValue());
604610
}

build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/BuildInfoRecorderLifecycleParticipant.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ private ArtifactoryClientConfiguration getConfiguration(MavenSession session) {
7474
allMavenProps.putAll(session.getSystemProperties());
7575
allMavenProps.putAll(session.getUserProperties());
7676

77-
Maven3BuildInfoLogger log = new Maven3BuildInfoLogger(logger);
78-
Properties allProps = BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(allMavenProps, log);
79-
internalConfiguration = new ArtifactoryClientConfiguration(log);
77+
Properties allProps = BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(allMavenProps);
78+
internalConfiguration = new ArtifactoryClientConfiguration(new Maven3BuildInfoLogger(logger));
8079
internalConfiguration.fillFromProperties(allProps);
8180
return internalConfiguration;
8281
}

build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/resolver/ResolutionHelper.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ public void resolve(Properties allMavenProps, Logger logger) {
2828
return;
2929
}
3030

31-
Maven3BuildInfoLogger log = new Maven3BuildInfoLogger(logger);
32-
Properties allProps = BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(allMavenProps, log);
33-
internalConfiguration = new ArtifactoryClientConfiguration(log);
31+
Properties allProps = BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(allMavenProps);
32+
internalConfiguration = new ArtifactoryClientConfiguration(new Maven3BuildInfoLogger(logger));
3433
internalConfiguration.fillFromProperties(allProps);
3534
}
3635

build-info-extractor/src/main/java/org/jfrog/build/extractor/BuildInfoExtractorUtils.java

+16-35
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@
3232
import org.jfrog.build.api.Build;
3333
import org.jfrog.build.api.BuildInfoConfigProperties;
3434
import org.jfrog.build.api.BuildInfoProperties;
35-
import org.jfrog.build.api.util.Log;
3635
import org.jfrog.build.client.ClientProperties;
3736
import org.jfrog.build.client.IncludeExcludePatterns;
3837
import org.jfrog.build.client.PatternMatcher;
3938

40-
import java.io.*;
39+
import java.io.File;
40+
import java.io.FileInputStream;
41+
import java.io.IOException;
42+
import java.io.InputStream;
43+
import java.io.StringReader;
44+
import java.io.StringWriter;
4145
import java.util.HashMap;
4246
import java.util.Map;
4347
import java.util.Properties;
@@ -61,9 +65,9 @@ public abstract class BuildInfoExtractorUtils {
6165
public static final Predicate<Object> MATRIX_PARAM_PREDICATE =
6266
new PrefixPredicate(ClientProperties.PROP_DEPLOY_PARAM_PROP_PREFIX);
6367

64-
public static Properties mergePropertiesWithSystemAndPropertyFile(Properties existingProps, Log log) {
68+
public static Properties mergePropertiesWithSystemAndPropertyFile(Properties existingProps) {
6569
Properties props = new Properties();
66-
String propertiesFilePath = getAdditionalPropertiesFile(existingProps, log);
70+
String propertiesFilePath = getAdditionalPropertiesFile(existingProps);
6771
if (StringUtils.isNotBlank(propertiesFilePath)) {
6872
File propertiesFile = new File(propertiesFilePath);
6973
InputStream inputStream = null;
@@ -111,7 +115,7 @@ public static Properties stripPrefixFromProperties(Properties source, String pre
111115
return props;
112116
}
113117

114-
public static Properties getEnvProperties(Properties startProps, Log log) {
118+
public static Properties getEnvProperties(Properties startProps) {
115119
IncludeExcludePatterns patterns = new IncludeExcludePatterns(
116120
startProps.getProperty(BuildInfoConfigProperties.PROP_ENV_VARS_INCLUDE_PATTERNS),
117121
startProps.getProperty(BuildInfoConfigProperties.PROP_ENV_VARS_EXCLUDE_PATTERNS));
@@ -147,7 +151,7 @@ public static Properties getEnvProperties(Properties startProps, Log log) {
147151
}
148152

149153
// TODO: [by FSI] Test if this is needed! Since start props are used now
150-
String propertiesFilePath = getAdditionalPropertiesFile(startProps, log);
154+
String propertiesFilePath = getAdditionalPropertiesFile(startProps);
151155
if (StringUtils.isNotBlank(propertiesFilePath)) {
152156
File propertiesFile = new File(propertiesFilePath);
153157
InputStream inputStream = null;
@@ -211,40 +215,17 @@ public static void saveBuildInfoToFile(Build build, File toFile) throws IOExcept
211215
Files.write(buildInfoJson, toFile, Charsets.UTF_8);
212216
}
213217

214-
private static String getAdditionalPropertiesFile(Properties additionalProps, Log log) {
218+
private static String getAdditionalPropertiesFile(Properties additionalProps) {
215219
String key = BuildInfoConfigProperties.PROP_PROPS_FILE;
216220
String propertiesFilePath = System.getProperty(key);
217-
String propFoundPath = "";
218221
if (StringUtils.isBlank(propertiesFilePath) && additionalProps != null) {
219222
propertiesFilePath = additionalProps.getProperty(key);
220-
propFoundPath = "additionalProps.getProperty";
221-
}
222-
if (StringUtils.isBlank(propertiesFilePath)) {
223-
// Jenkins prefixes these variables with "env." so let's try that
224-
propertiesFilePath = additionalProps.getProperty("env." + key);
225-
if (StringUtils.isBlank(propertiesFilePath)) {
226-
propertiesFilePath = System.getenv(key);
227-
propFoundPath = StringUtils.isBlank(propertiesFilePath) ? "" : "System.getenv";
228-
} else {
229-
propFoundPath = "additionalProps.getProperty(\"env.\" + key)";
230-
}
231-
}
232-
if (StringUtils.isBlank(propertiesFilePath)) {
233-
// Jenkins prefixes these variables with "env." so let's try that
234-
key = BuildInfoConfigProperties.ENV_BUILDINFO_PROPFILE;
235-
propertiesFilePath = additionalProps.getProperty("env." + key);
236223
if (StringUtils.isBlank(propertiesFilePath)) {
237-
propertiesFilePath = System.getenv(key);
238-
propFoundPath = StringUtils.isBlank(propertiesFilePath) ? "" : " second System.getenv";
239-
} else {
240-
propFoundPath = "additionalProps.getProperty(\"env.\" + key)";
241-
}
242-
}
243-
if (log != null) {
244-
if (StringUtils.isBlank(propFoundPath)) {
245-
log.warn("[buildinfo] Properties file path was not found, this build will probably fail");
246-
} else {
247-
log.debug("[buildinfo] Properties file " + propertiesFilePath + " retrieved from " + propFoundPath);
224+
// Jenkins prefixes these variables with "env." so let's try that
225+
propertiesFilePath = additionalProps.getProperty("env." + key);
226+
if (StringUtils.isBlank(propertiesFilePath)) {
227+
propertiesFilePath = System.getenv(key);
228+
}
248229
}
249230
}
250231
return propertiesFilePath;

0 commit comments

Comments
 (0)