Skip to content

Commit 7c68b83

Browse files
Excavator: Format Java files
1 parent 8806a8b commit 7c68b83

File tree

12 files changed

+193
-102
lines changed

12 files changed

+193
-102
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(c) Copyright ${today.year} Palantir Technologies Inc. All rights reserved.

src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public LockState readLocks() {
6868
return LockState.from(parseLines(productionDeps), parseLines(testDeps));
6969
} catch (IOException e) {
7070
throw new GradleException(
71-
String.format("Couldn't load versions from palantir dependency lock file: %s", lockfile), e);
71+
String.format("Couldn't load versions from palantir dependency lock file: %s", lockfile),
72+
e);
7273
}
7374
}
7475

@@ -93,10 +94,11 @@ public Stream<Line> parseLines(Stream<String> stringStream) {
9394

9495
public void writeLocks(FullLockState fullLockState) {
9596
LockState lockState = LockStates.toLockState(fullLockState);
96-
try (BufferedWriter writer = Files.newBufferedWriter(
97-
lockfile,
98-
StandardOpenOption.CREATE,
99-
StandardOpenOption.TRUNCATE_EXISTING)) {
97+
try (
98+
BufferedWriter writer = Files.newBufferedWriter(
99+
lockfile,
100+
StandardOpenOption.CREATE,
101+
StandardOpenOption.TRUNCATE_EXISTING)) {
100102
writer.append(HEADER_COMMENT);
101103
writer.newLine();
102104

src/main/java/com/palantir/gradle/versions/FixLegacyJavaConfigurationsPlugin.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ private void fixLegacyResolvableJavaConfigurations(Project project, Configuratio
6565
injectVersions(
6666
conf,
6767
(group, name) -> GetVersionPlugin.getOptionalVersion(
68-
project, group, name, unifiedClasspath));
68+
project,
69+
group,
70+
name,
71+
unifiedClasspath));
6972
}));
7073
}
7174

src/main/java/com/palantir/gradle/versions/GetVersionPlugin.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ public void apply(Project project) {
4242
* This is the preferred signature because it's shortest.
4343
*/
4444
public String doCall(Object moduleVersion) {
45-
return doCall(moduleVersion, project.getRootProject()
46-
.getConfigurations()
47-
.getByName(VersionsLockPlugin.UNIFIED_CLASSPATH_CONFIGURATION_NAME));
45+
return doCall(moduleVersion,
46+
project.getRootProject()
47+
.getConfigurations()
48+
.getByName(VersionsLockPlugin.UNIFIED_CLASSPATH_CONFIGURATION_NAME));
4849
}
4950

5051
/** Find a version from another configuration, e.g. from the gradle-docker plugin. */
@@ -60,9 +61,12 @@ public String doCall(Object moduleVersion, Configuration configuration) {
6061

6162
/** This matches the signature of nebula's dependencyRecommendations.getRecommendedVersion. */
6263
public String doCall(String group, String name) {
63-
return getVersion(project, group, name, project.getRootProject()
64-
.getConfigurations()
65-
.getByName(VersionsLockPlugin.UNIFIED_CLASSPATH_CONFIGURATION_NAME));
64+
return getVersion(project,
65+
group,
66+
name,
67+
project.getRootProject()
68+
.getConfigurations()
69+
.getByName(VersionsLockPlugin.UNIFIED_CLASSPATH_CONFIGURATION_NAME));
6670
}
6771

6872
public String doCall(String group, String name, Configuration configuration) {
@@ -77,7 +81,10 @@ private static String getVersion(Project project, String group, String name, Con
7781
}
7882

7983
static Optional<String> getOptionalVersion(
80-
Project project, String group, String name, Configuration configuration) {
84+
Project project,
85+
String group,
86+
String name,
87+
Configuration configuration) {
8188
if (GradleWorkarounds.isConfiguring(project.getState())) {
8289
throw new GradleException(
8390
String.format("Not allowed to call gradle-consistent-versions's getVersion(\"%s\", \"%s\", "
@@ -99,7 +106,10 @@ static Optional<String> getOptionalVersion(
99106

100107
if (list.size() > 1) {
101108
throw new GradleException(String.format("Multiple modules matching '%s:%s' in %s: %s",
102-
group, name, configuration, list));
109+
group,
110+
name,
111+
configuration,
112+
list));
103113
}
104114

105115
return Optional.of(Iterables.getOnlyElement(list).getVersion());
@@ -116,6 +126,9 @@ private static GradleException notFound(String group, String name, Configuration
116126
return new GradleException(String.format(
117127
"Unable to find '%s:%s' in %s. This may happen if you specify the version in versions.props but do not"
118128
+ " have a dependency in the configuration. The configuration contained:\n%s",
119-
group, name, configuration, actual));
129+
group,
130+
name,
131+
configuration,
132+
actual));
120133
}
121134
}

src/main/java/com/palantir/gradle/versions/GradleWorkarounds.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ static boolean isConfiguring(ProjectState state) {
5757
Class<?> stateInternal = Class.forName("org.gradle.api.internal.project.ProjectStateInternal");
5858
Object internal = stateInternal.cast(state);
5959
return (boolean) stateInternal.getDeclaredMethod("isConfiguring").invoke(internal);
60-
} catch (ClassNotFoundException | ClassCastException | NoSuchMethodException
61-
| IllegalAccessException | InvocationTargetException e) {
60+
} catch (
61+
ClassNotFoundException
62+
| ClassCastException
63+
| NoSuchMethodException
64+
| IllegalAccessException
65+
| InvocationTargetException e) {
6266
log.warn("Couldn't use ProjectStateInternal to determine whether project is configuring", e);
6367
// This is an approximation the public API exposes.
6468
// It will give us a false negative if we're in 'afterEvaluate'
@@ -75,14 +79,14 @@ static boolean isConfiguring(ProjectState state) {
7579
static <T> ListProperty<T> fixListProperty(ListProperty<T> property) {
7680
Class<?> propertyInternalClass = org.gradle.api.internal.provider.CollectionPropertyInternal.class;
7781
return (ListProperty<T>) Proxy.newProxyInstance(GradleWorkarounds.class.getClassLoader(),
78-
new Class<?>[]{
82+
new Class<?>[] {
7983
org.gradle.api.internal.provider.CollectionProviderInternal.class,
8084
ListProperty.class},
8185
(proxy, method, args) -> {
8286
// Find matching method on CollectionPropertyInternal
8387
//org.gradle.api.internal.provider.CollectionProviderInternal
84-
if (method.getDeclaringClass()
85-
== org.gradle.api.internal.provider.CollectionProviderInternal.class) {
88+
if (method
89+
.getDeclaringClass() == org.gradle.api.internal.provider.CollectionProviderInternal.class) {
8690
if (method.getName().equals("getElementType")) {
8791
// Proxy to `propertyInternalClass` which we know DefaultListProperty implements.
8892
return propertyInternalClass.getMethod(method.getName(), method.getParameterTypes())
@@ -112,7 +116,8 @@ static <T> ListProperty<T> fixListProperty(ListProperty<T> property) {
112116
* </ul>
113117
*/
114118
static <T extends ModuleDependency> T fixAttributesOfModuleDependency(
115-
ObjectFactory objectFactory, T dependency) {
119+
ObjectFactory objectFactory,
120+
T dependency) {
116121
if (GradleVersion.current().compareTo(GradleVersion.version("5.6")) >= 0
117122
// Merged on 2019-06-12 so next nightly should be good
118123
|| GradleVersion.current().compareTo(GradleVersion.version("5.6-20190613000000+0000")) >= 0) {
@@ -166,8 +171,8 @@ private static boolean isPlatformPre53(AttributeContainer attributes) {
166171

167172
static boolean isFailOnVersionConflict(Configuration conf) {
168173
org.gradle.api.internal.artifacts.configurations.ConflictResolution conflictResolution =
169-
((org.gradle.api.internal.artifacts.configurations.ResolutionStrategyInternal)
170-
conf.getResolutionStrategy()).getConflictResolution();
174+
((org.gradle.api.internal.artifacts.configurations.ResolutionStrategyInternal) conf
175+
.getResolutionStrategy()).getConflictResolution();
171176
return conflictResolution == org.gradle.api.internal.artifacts.configurations.ConflictResolution.strict;
172177
}
173178

src/main/java/com/palantir/gradle/versions/VerifyLocksTask.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,37 @@ private void verifyLocksForScope(
8484
Set<MyModuleIdentifier> missing = difference.entriesOnlyOnLeft().keySet();
8585
if (!missing.isEmpty()) {
8686
throw new RuntimeException(
87-
"Locked dependencies missing from the resolution result: " + missing + ". "
87+
"Locked dependencies missing from the resolution result: " + missing
88+
+ ". "
8889
+ ". Please run './gradlew --write-locks'.");
8990
}
9091

9192
Set<MyModuleIdentifier> unknown = difference.entriesOnlyOnRight().keySet();
9293
if (!unknown.isEmpty()) {
9394
throw new RuntimeException(
94-
"Found dependencies that were not in the lock state: " + unknown + ". "
95+
"Found dependencies that were not in the lock state: " + unknown
96+
+ ". "
9597
+ "Please run './gradlew --write-locks'.");
9698
}
9799

98100
Map<MyModuleIdentifier, ValueDifference<Line>> differing = difference.entriesDiffering();
99101
if (!differing.isEmpty()) {
100102
throw new RuntimeException("Found dependencies whose dependents changed:\n"
101-
+ formatDependencyDifferences(differing) + "\n\n"
103+
+ formatDependencyDifferences(differing)
104+
+ "\n\n"
102105
+ "Please run './gradlew --write-locks'.");
103106
}
104107
}
105108

106109
private static String formatDependencyDifferences(
107110
Map<MyModuleIdentifier, ValueDifference<Line>> differing) {
108-
return differing.entrySet().stream().map(diff -> String.format("" // to align strings
111+
return differing.entrySet()
112+
.stream()
113+
.map(diff -> String.format("" // to align strings
109114
+ "-%s\n"
110115
+ "+%s",
111-
diff.getValue().leftValue().stringRepresentation(),
112-
diff.getValue().rightValue().stringRepresentation())).collect(Collectors.joining("\n"));
116+
diff.getValue().leftValue().stringRepresentation(),
117+
diff.getValue().rightValue().stringRepresentation()))
118+
.collect(Collectors.joining("\n"));
113119
}
114120
}

0 commit comments

Comments
 (0)