Skip to content

Commit

Permalink
Rename recipe options and inline visitor and method
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Jan 7, 2025
1 parent fd71955 commit b3f17ce
Showing 1 changed file with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,33 @@ public String getDescription() {
example = "true",
required = false)
@Nullable
String buildCacheLocalEnabled;
String localEnabled;

@Option(displayName = "Enable remote build cache",
description = "Value for `//develocity/buildCache/remote/enabled`.",
example = "true",
required = false)
@Nullable
String buildCacheRemoteEnabled;
String remoteEnabled;

@Option(displayName = "Enable remote build cache store",
description = "Value for `//develocity/buildCache/remote/storeEnabled`.",
example = "#{isTrue(env['CI'])}",
required = false)
@Nullable
String buildCacheRemoteStoreEnabled;
String remoteStoreEnabled;

@Override
public Validated<Object> validate(ExecutionContext ctx) {
return super.validate(ctx)
.and(Validated.notBlank("buildCacheLocalEnabled", buildCacheLocalEnabled)
.or(Validated.notBlank("buildCacheRemoteEnabled", buildCacheRemoteEnabled))
.or(Validated.notBlank("buildCacheRemoteStoreEnabled", buildCacheRemoteStoreEnabled)));
.and(Validated.notBlank("localEnabled", localEnabled)
.or(Validated.notBlank("remoteEnabled", remoteEnabled))
.or(Validated.notBlank("remoteStoreEnabled", remoteStoreEnabled)));
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
XmlVisitor<ExecutionContext> visitor = new XmlVisitor<ExecutionContext>() {
return Preconditions.check(new FindSourceFiles(".mvn/*.xml"), new XmlVisitor<ExecutionContext>() {
@Override
public Xml visitDocument(Xml.Document document, ExecutionContext ctx) {
Xml.Tag rootTag = document.getRoot();
Expand All @@ -81,29 +81,27 @@ public Xml visitDocument(Xml.Document document, ExecutionContext ctx) {
}
return document;
}
};

return Preconditions.check(new FindSourceFiles(".mvn/*.xml"), visitor);
}

private String buildCacheConfig() {
StringBuilder sb = new StringBuilder("<buildCache>");
if (!StringUtils.isBlank(buildCacheLocalEnabled)) {
sb.append("<local>");
sb.append("<enabled>").append(buildCacheLocalEnabled).append("</enabled>");
sb.append("</local>");
}
if (!StringUtils.isBlank(buildCacheRemoteEnabled) || !StringUtils.isBlank(buildCacheRemoteStoreEnabled)) {
sb.append("<remote>");
if (!StringUtils.isBlank(buildCacheRemoteEnabled)) {
sb.append("<enabled>").append(buildCacheRemoteEnabled).append("</enabled>");
}
if (!StringUtils.isBlank(buildCacheRemoteStoreEnabled)) {
sb.append("<storeEnabled>").append(buildCacheRemoteStoreEnabled).append("</storeEnabled>");
private String buildCacheConfig() {
StringBuilder sb = new StringBuilder("<buildCache>");
if (!StringUtils.isBlank(localEnabled)) {
sb.append("<local>");
sb.append("<enabled>").append(localEnabled).append("</enabled>");
sb.append("</local>");
}
if (!StringUtils.isBlank(remoteEnabled) || !StringUtils.isBlank(remoteStoreEnabled)) {
sb.append("<remote>");
if (!StringUtils.isBlank(remoteEnabled)) {
sb.append("<enabled>").append(remoteEnabled).append("</enabled>");
}
if (!StringUtils.isBlank(remoteStoreEnabled)) {
sb.append("<storeEnabled>").append(remoteStoreEnabled).append("</storeEnabled>");
}
sb.append("</remote>");
}
sb.append("</buildCache>");
return sb.toString();
}
sb.append("</remote>");
}
sb.append("</buildCache>");
return sb.toString();
});
}
}

0 comments on commit b3f17ce

Please sign in to comment.