|
14 | 14 |
|
15 | 15 | plugins { |
16 | 16 | 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 | | - } |
26 | 17 | } |
27 | 18 |
|
28 | 19 | 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 | + |
29 | 30 | implementation project(':palantir-java-format') |
30 | 31 | implementation libs.jsr305 |
31 | 32 | } |
32 | 33 |
|
| 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 | + |
33 | 40 | tasks.named("jar", Jar) { |
34 | 41 | archiveBaseName = 'palantir-java-format-eclipse-plugin' |
| 42 | + |
35 | 43 | manifest { |
36 | 44 | 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 | + }) |
37 | 53 | } |
38 | | - // We embed some dependencies into the JAR file |
39 | | - from(configurations.runtimeClasspath) { |
| 54 | + |
| 55 | + from(embeddedLibs) { |
40 | 56 | 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') |
44 | 57 | } |
45 | 58 | } |
0 commit comments