Intellij uses the native image from .gradle/palantir-java-formatter-caches#1306
Intellij uses the native image from .gradle/palantir-java-formatter-caches#1306bulldozer-bot[bot] merged 11 commits intodevelopfrom
.gradle/palantir-java-formatter-caches#1306Conversation
Generate changelog in
|
…/palantir-java-format into cr/fix-missing-native-image-dir
|
adding |
| import java.util.Comparator; | ||
| import java.util.stream.Stream; | ||
|
|
||
| public final class FileUtils { |
There was a problem hiding this comment.
same as in gradle-jdks
|
|
||
| private static Logger logger = Logging.getLogger(PalantirJavaFormatIdeaPlugin.class); | ||
|
|
||
| public static URI copyToCacheDir(URI srcUri) { |
There was a problem hiding this comment.
similar to the logic in gradle-jdks https://github.com/palantir/gradle-jdks/blob/develop/gradle-jdks-setup/src/main/java/com/palantir/gradle/jdks/setup/GradleJdkInstallationSetup.java#L114 with a few modification eg. not copying a directory, but a file
|
|
||
| Optional<Configuration> nativeImplConfiguration = maybeGetNativeImplConfiguration(rootProject); | ||
|
|
||
| configureLegacyIdea(rootProject, implConfiguration, nativeImplConfiguration); |
There was a problem hiding this comment.
Removed the configureLegacyIdea logic completely. I see that we did that in gradle-idea-configuration as well but happy to bring it back if you think this might be problematic for some usecases.
| if (!Boolean.getBoolean("idea.active")) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
I am not sure here - do we still need to check the idea.active and run this when the idea plugin is applied ?
| return Path.of(Optional.ofNullable(System.getenv("GRADLE_USER_HOME")) | ||
| .orElseGet(() -> System.getenv("HOME") + "/.gradle")); |
There was a problem hiding this comment.
I think we can use project.getGradle().getGradleUserHomeDir() instead
| TaskProvider<UpdatePalantirJavaFormatIdeaXmlFile> updatePalantirJavaFormatIpr = rootProject | ||
| .getTasks() | ||
| .register("updatePalantirJavaFormatIpr", UpdatePalantirJavaFormatIdeaXmlFile.class, task -> { | ||
| task.getOutputFile().set(rootProject.file(rootProject.getName() + ".ipr")); | ||
| task.getShouldCreateOutputIfAbsent().set(false); | ||
| }); |
There was a problem hiding this comment.
do we still need this? I don't have any .ipr files in my directories anymore
There was a problem hiding this comment.
I think we could probably drop the old way now. We've had the huge warning via baseline for ages now, and it's super deprecated.
| TaskProvider<UpdateWorkspaceXmlFile> updateWorkspaceIwsXml = rootProject | ||
| .getTasks() | ||
| .register("updateWorkspaceIwsXml", UpdateWorkspaceXmlFile.class, task -> { | ||
| task.getOutputFile().set(rootProject.file(rootProject.getName() + ".iws")); | ||
| task.getShouldCreateOutputIfAbsent().set(false); | ||
| }); |
There was a problem hiding this comment.
similarly here, isn't this just the idea logic?
| @OutputDirectory | ||
| public abstract RegularFileProperty getCacheDir(); |
There was a problem hiding this comment.
This cache dir can have multiple different formatters in it right? If so, we should just have a single output that is the file we expect it to be in, otherwise Gradle will regard this task not up-to-date as extra stuff gets added to it.
| java.util.Optional<URI> nativeUri = getNativeImageConfig().isEmpty() | ||
| ? java.util.Optional.empty() | ||
| : java.util.Optional.of(getNativeImageConfig().getSingleFile().toURI()) |
There was a problem hiding this comment.
I'd probably preferentially import java.util.Optional and fully qualify the org.gradle.api.tasks.Optional to make this a bit more readable.
| getImplementationConfig().getFiles().stream().map(File::toURI).collect(Collectors.toList()); | ||
| java.util.Optional<URI> nativeUri = getNativeImageConfig().isEmpty() | ||
| ? java.util.Optional.empty() | ||
| : java.util.Optional.of(getNativeImageConfig().getSingleFile().toURI()) |
There was a problem hiding this comment.
Instead of this, you can use getImplementationConfig().getFiles().stream().findFirst().map(File::toUri)
|
Released 2.72.0 |
Before this PR
Unused artifact transforms are cleaned up by Gradle every 7 days. This could lead to situation - if people do not refresh the Gradle project in Intellij - where the formatter would fail to run because:
internal slack thread here
After this PR
~/.gradle/palantir-java-formatter-caches).==COMMIT_MSG==
Intellij uses the native image from
.gradle/palantir-java-formatter-caches==COMMIT_MSG==
Possible downsides?