Skip to content

Commit f6667a2

Browse files
committed
Update eclipse configuration
1 parent 0eb21c4 commit f6667a2

4 files changed

Lines changed: 40 additions & 23 deletions

File tree

‎eclipse_plugin/build.gradle‎

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,45 @@
1414

1515
plugins {
1616
id 'java-library'
17-
id 'dev.equo.p2deps' version '1.7.8'
18-
}
19-
20-
p2deps {
21-
into 'compileOnly', {
22-
p2repo 'https://download.eclipse.org/releases/2020-09/202009161000/'
23-
24-
install 'org.eclipse.jdt.core'
25-
}
2617
}
2718

2819
dependencies {
20+
// Was dev.equo.p2deps resolving these from an Eclipse p2 repository at configuration time:
21+
// a network fetch on every configuration, and a parse of the metadata index of an entire
22+
// Eclipse release — which now exceeds the JDK's JAXP entity-size limit and fails the build.
23+
// Same bundles, from Maven Central, resolved like every other dependency. compileOnly because
24+
// the host IDE provides them at runtime; MANIFEST.MF imports the packages without version
25+
// ranges, so the versions here only have to satisfy the compiler.
26+
compileOnly libs.eclipse.jdtCore
27+
compileOnly libs.eclipse.jfaceText
28+
compileOnly libs.eclipse.text
29+
2930
implementation project(':palantir-java-format')
3031
implementation libs.jsr305
3132
}
3233

34+
// The dependencies embedded in the plugin jar. Named once, so the manifest can list exactly what
35+
// was packaged rather than a guess at what the file names will be.
36+
def embeddedLibs = configurations.runtimeClasspath.filter { file ->
37+
['functionaljava', 'guava', 'palantir'].any { file.name.startsWith(it) }
38+
}
39+
3340
tasks.named("jar", Jar) {
3441
archiveBaseName = 'palantir-java-format-eclipse-plugin'
42+
3543
manifest {
3644
from 'src/main/resources/META-INF/MANIFEST.MF'
45+
// Generated, not hardcoded. There used to be a rename() stripping versions off the
46+
// embedded jars so their names would match a fixed Bundle-ClassPath, but its pattern only
47+
// matched plain versions: on any build whose version comes from `git describe`
48+
// (2.97.0-26-g9da6ae7.dirty) the rename silently did nothing and the manifest pointed at
49+
// files that were not in the archive, so Eclipse could not load the plugin.
50+
attributes('Bundle-ClassPath': embeddedLibs.elements.map { files ->
51+
(['.'] + files.collect { "lib/${it.asFile.name}" }).join(',')
52+
})
3753
}
38-
// We embed some dependencies into the JAR file
39-
from(configurations.runtimeClasspath) {
54+
55+
from(embeddedLibs) {
4056
into 'lib'
41-
include('functionaljava*', 'guava*', 'palantir*')
42-
// The libraries are listed without a version in the manifest
43-
rename('(.*)-[0-9b.]+(\\.dirty|-jre)?\\.jar', '$1.jar')
4457
}
4558
}

‎eclipse_plugin/src/main/resources/META-INF/MANIFEST.MF‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,3 @@ Import-Package: org.eclipse.jdt.core.dom,
88
org.eclipse.jdt.core.formatter,
99
org.eclipse.jface.text,
1010
org.eclipse.text.edits
11-
Bundle-ClassPath: .,
12-
lib/functionaljava.jar,
13-
lib/guava.jar,
14-
lib/palantir-java-format.jar,
15-
lib/palantir-java-format-spi.jar

‎gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/NativeImageSupport.java‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.palantir.javaformat.gradle;
1818

19-
import com.palantir.platform.Architecture;
2019
import com.palantir.platform.GradleOperatingSystem;
2120
import com.palantir.platform.OperatingSystem;
2221
import javax.inject.Inject;
@@ -35,11 +34,15 @@ public boolean isNativeImageConfigured() {
3534
return isNativeFlagEnabled() && isNativeImageSupported();
3635
}
3736

37+
/**
38+
* The platforms a native image is published for, and therefore the only ones where it can be
39+
* resolved. macOS is supported on both architectures: the x86-64 image used to be excluded
40+
* because nobody built it, and .github/workflows/ci.yml now does. Windows and musl are still
41+
* absent for the same reason — no job produces them.
42+
*/
3843
private boolean isNativeImageSupported() {
3944
return getOs().getOperatingSystem()
40-
.map(os -> os.equals(OperatingSystem.LINUX_GLIBC)
41-
|| (os.equals(OperatingSystem.MACOS)
42-
&& Architecture.get().equals(Architecture.AARCH64)))
45+
.map(os -> os.equals(OperatingSystem.LINUX_GLIBC) || os.equals(OperatingSystem.MACOS))
4346
.get();
4447
}
4548

‎gradle/libs.versions.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
# updates it, which it could not do for versions.props.
44

55
[libraries]
6+
# Eclipse bundles the plugin compiles against. compileOnly: at runtime the host IDE
7+
# provides them, and META-INF/MANIFEST.MF imports the packages without version ranges.
8+
# Versions here match Eclipse 2020-09, which is what the p2 repository used to resolve.
9+
eclipse-jdtCore = { module = "org.eclipse.jdt:org.eclipse.jdt.core", version = "3.23.0" }
10+
eclipse-jfaceText = { module = "org.eclipse.platform:org.eclipse.jface.text", version = "3.16.300" }
11+
eclipse-text = { module = "org.eclipse.platform:org.eclipse.text", version = "3.10.200" }
612
jetbrainsAnnotations = { module = "org.jetbrains:annotations", version = "26.1.0" }
713
# A platform, not a dependency: plugins (baseline) inject versionless JUnit artifacts such as
814
# junit-platform-launcher, and versions.props used to supply their versions.

0 commit comments

Comments
 (0)