-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The standalone `com.palantir.java-format` plugin provides a `formatDiff` task. IntelliJ setup has been moved to a `com.palantir.java-format-idea` plugin.
- Loading branch information
1 parent
9af36ba
commit 4cceef8
Showing
27 changed files
with
597 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type: break | ||
break: | ||
description: The standalone `com.palantir.java-format` plugin provides a `formatDiff` | ||
task. IntelliJ setup has been moved to a `com.palantir.java-format-idea` plugin. | ||
links: | ||
- https://github.com/palantir/palantir-java-format/pull/48 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...rmat/src/main/groovy/com/palantir/javaformat/gradle/ConfigureExternalDependenciesXml.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...va-format/src/main/groovy/com/palantir/javaformat/gradle/ConfigureJavaFormatterXml.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...format/src/main/groovy/com/palantir/javaformat/gradle/ConfigurePalantirJavaFormatXml.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...tir-java-format/src/main/groovy/com/palantir/javaformat/gradle/UpdateIntellijXmlTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 39 additions & 10 deletions
49
...alantir-java-format/src/main/java/com/palantir/javaformat/gradle/JavaFormatExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,48 @@ | ||
/* | ||
* (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.palantir.javaformat.gradle; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.provider.Property; | ||
import com.google.common.collect.Iterables; | ||
import com.palantir.javaformat.java.FormatterService; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.util.ServiceLoader; | ||
import org.gradle.api.artifacts.Configuration; | ||
|
||
public class JavaFormatExtension { | ||
private final Property<String> implementationVersion; | ||
private static final String IMPLEMENTATION_VERSION = | ||
JavaFormatExtension.class.getPackage().getImplementationVersion(); | ||
private final Configuration configuration; | ||
|
||
public JavaFormatExtension(Project project) { | ||
implementationVersion = project.getObjects().property(String.class); | ||
implementationVersion.set(IMPLEMENTATION_VERSION); | ||
public JavaFormatExtension(Configuration configuration) { | ||
this.configuration = configuration; | ||
} | ||
|
||
public final Property<String> getImplementationVersion() { | ||
return implementationVersion; | ||
public FormatterService serviceLoad() { | ||
URL[] jarUris = configuration.getFiles().stream() | ||
.map(file -> { | ||
try { | ||
return file.toURI().toURL(); | ||
} catch (MalformedURLException e) { | ||
throw new RuntimeException("Unable to convert URI to URL: " + file, e); | ||
} | ||
}) | ||
.toArray(URL[]::new); | ||
|
||
ClassLoader classLoader = new URLClassLoader(jarUris, FormatterService.class.getClassLoader()); | ||
return Iterables.getOnlyElement(ServiceLoader.load(FormatterService.class, classLoader)); | ||
} | ||
} |
Oops, something went wrong.