Skip to content

Commit 93ee8fe

Browse files
tobousgoogle-java-format Team
authored andcommitted
Fix Eclipse plugin build
Updates the Eclipse plugin build logic. The logic is now completely separate from the main google java format build. Instead of relying on the build artifacts of the core build, the needed google-java-format and guava build artifacts used for the build are now pulled from maven. Updates google-java-format version used for the build to '1.9', the build JDK to 11, and removes old dependencies which are no longer used. Updates tycho version to 1.7.0 in order to build with JDK > 8. Updates the build guide in the README. Fixes #465 COPYBARA_INTEGRATE_REVIEW=#465 from tobous:fix-eclipse-build e80a72b PiperOrigin-RevId: 387615841
1 parent cc8b96f commit 93ee8fe

File tree

6 files changed

+109
-93
lines changed

6 files changed

+109
-93
lines changed

core/pom.xml

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -156,51 +156,6 @@
156156
</archive>
157157
</configuration>
158158
</plugin>
159-
<plugin>
160-
<artifactId>maven-resources-plugin</artifactId>
161-
<version>3.0.1</version>
162-
<executions>
163-
<execution>
164-
<id>copy-resources</id>
165-
<phase>package</phase>
166-
<goals>
167-
<goal>copy-resources</goal>
168-
</goals>
169-
<configuration>
170-
<outputDirectory>../eclipse_plugin/lib</outputDirectory>
171-
<resources>
172-
<resource>
173-
<directory>target</directory>
174-
<include>${project.artifactId}-${project.version}.jar</include>
175-
</resource>
176-
</resources>
177-
</configuration>
178-
</execution>
179-
</executions>
180-
</plugin>
181-
<plugin>
182-
<groupId>org.apache.maven.plugins</groupId>
183-
<artifactId>maven-dependency-plugin</artifactId>
184-
<version>2.10</version>
185-
<executions>
186-
<execution>
187-
<id>copy-dependencies</id>
188-
<phase>package</phase>
189-
<goals>
190-
<goal>copy-dependencies</goal>
191-
</goals>
192-
<configuration>
193-
<outputDirectory>../eclipse_plugin/lib</outputDirectory>
194-
<overWriteReleases>true</overWriteReleases>
195-
<overWriteSnapshots>true</overWriteSnapshots>
196-
<excludeTransitive>true</excludeTransitive>
197-
<excludeArtifactIds>org.eclipse.jdt.core</excludeArtifactIds>
198-
<excludeScope>compile</excludeScope>
199-
<excludeScope>provided</excludeScope>
200-
</configuration>
201-
</execution>
202-
</executions>
203-
</plugin>
204159
<plugin>
205160
<groupId>com.google.code.maven-replacer-plugin</groupId>
206161
<artifactId>replacer</artifactId>

eclipse_plugin/META-INF/MANIFEST.MF

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: google-java-format
44
Bundle-SymbolicName: google-java-format-eclipse-plugin;singleton:=true
5-
Bundle-Version: 1.6.0
6-
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
5+
Bundle-Vendor: Google
6+
Bundle-Version: 1.9.0
7+
Bundle-RequiredExecutionEnvironment: JavaSE-11
78
Require-Bundle: org.eclipse.jdt.core;bundle-version="3.10.0",
89
org.eclipse.jface,
910
org.eclipse.text,
1011
org.eclipse.ui,
1112
org.eclipse.equinox.common
1213
Bundle-ClassPath: .,
13-
lib/guava-22.0.jar,
14-
lib/javac-shaded-9+181-r4173-1.jar,
15-
lib/google-java-format-1.6.jar
14+
lib/guava-28.1-jre.jar,
15+
lib/google-java-format-1.9.jar

eclipse_plugin/README.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
1-
# google-java-format Eclipse Plugin
1+
# Google Java Format Eclipse Plugin
22

33
## Enabling
44

55
See https://github.com/google/google-java-format#eclipse
66

77
## Development
88

9-
1) Uncomment `<module>eclipse_plugin</module>` in the parent `pom.xml`
10-
11-
2) Run `mvn install`, which will copy the dependences of the plugin to
12-
`eclipse_plugin/lib`.
13-
14-
2) If you are using Java 9, add
15-
16-
```
17-
-vm
18-
/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java
19-
```
20-
21-
to `/Applications/Eclipse.app/Contents/Eclipse/eclipse.ini`.
22-
23-
3) Open the `eclipse_plugin` project in a recent Eclipse SDK build.
24-
25-
4) From `File > Export` select `Plugin-in Development > Deployable plugin-ins
26-
and fragments` and follow the wizard to export a plugin jar.
9+
### Prerequisites
10+
11+
Make sure that the `build.properties` and `META-INF/MANIFEST.MF` contain all
12+
necessary dependencies for the build. Furthermore, make sure that the
13+
dependencies declared in the `pom.xml` match the entries in `build.properties`
14+
and `META-INF/MANIFEST.MF`.
15+
16+
If the used google java format core version is a 'SNAPSHOT' release, the version
17+
for the Eclipse plugin in the `pom.xml` must end in '-SNAPSHOT' as well and the
18+
bundle version specified in `META-INF/MANIFEST.MF` must end in '.qualifier'.
19+
20+
### Building the Plugin
21+
22+
1) Run `mvn clean package` in the `eclipse_plugin` directory. This will first copy the dependencies
23+
of the plugin to `eclipse_plugin/lib/` and then triggers the tycho build that uses these
24+
dependencies (as declared in `build.properties`) for the actual Eclipse plugin build.<br><br>
25+
If you also want to add the build artifact to the local maven repository, you can use
26+
`mvn clean install -Dtycho.localArtifacts=ignore` instead. Note, however, that you then must use
27+
this build command for every build with that specific version number until you clear the build
28+
artifact (or the
29+
[p2-local-metadata.properties](https://wiki.eclipse.org/Tycho/Target_Platform#Locally_built_artifacts))
30+
from your local repository. Otherwise, you might run into issues caused by the build using an
31+
outdated build artifact created by a previous build instead of re-building the plugin. More
32+
information on this issue is given
33+
[in this thread](https://www.eclipse.org/lists/tycho-user/msg00952.html) and
34+
[this bug tracker entry](https://bugs.eclipse.org/bugs/show_bug.cgi?id=355367).
35+
36+
2) You can find the built plugin in
37+
`eclipse_plugin/target/google-java-format-eclipse-plugin-<version>.jar`
38+
39+
#### Building against a local (snapshot) release of the core
40+
41+
With the current build setup, the Eclipse plugin build pulls the needed build
42+
artifacts of the google java format core specified in the property
43+
`google-java-format.version` and copies it into the `eclipse_plugin/lib/`
44+
directory.
45+
46+
If you instead want to build against a local (snapshot) build of the core which
47+
is not available in a maven repository (local or otherwise), you will have to
48+
place the appropriate version into the `eclipse_plugin/lib/` directory yourself
49+
before the build.

eclipse_plugin/build.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ output.. = target/classes
33
bin.includes = META-INF/,\
44
.,\
55
plugin.xml,\
6-
lib/javac-shaded-9+181-r4173-1.jar,\
7-
lib/guava-22.0.jar,\
8-
lib/google-java-format-1.6.jar
6+
lib/guava-28.1-jre.jar,\
7+
lib/google-java-format-1.9.jar

eclipse_plugin/plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
13
<!--
24
Copyright 2020 Google Inc.
35
@@ -14,7 +16,6 @@
1416
limitations under the License.
1517
-->
1618

17-
<?xml version="1.0" encoding="UTF-8"?>
1819
<?eclipse version="3.4"?>
1920
<plugin>
2021
<extension point="org.eclipse.jdt.core.javaFormatter">

eclipse_plugin/pom.xml

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,47 @@
1414
~ limitations under the License.
1515
-->
1616

17-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1819
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1920
<modelVersion>4.0.0</modelVersion>
20-
<parent>
21-
<groupId>com.google.googlejavaformat</groupId>
22-
<artifactId>google-java-format-parent</artifactId>
23-
<version>1.6</version>
24-
</parent>
2521

22+
<groupId>com.google.googlejavaformat</groupId>
2623
<artifactId>google-java-format-eclipse-plugin</artifactId>
27-
<version>1.6.0</version>
2824
<packaging>eclipse-plugin</packaging>
29-
<name>google-java-format Plugin for Eclipse 4.5+</name>
25+
<version>1.9.0</version>
26+
27+
<name>Google Java Format Plugin for Eclipse 4.5+</name>
3028

3129
<description>
32-
A Java source code formatter that follows Google Java Style.
30+
A Java source code formatter plugin for Eclipse that follows Google Java Style.
3331
</description>
3432

3533
<properties>
36-
<tycho-version>0.26.0</tycho-version>
34+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
35+
36+
<tycho-version>1.7.0</tycho-version>
37+
38+
<!-- specific library versions; must match declarations in build.properties and META-INF/MANIFEST.MF -->
39+
<google-java-format.version>1.9</google-java-format.version>
40+
<guava.version>28.1-jre</guava.version>
3741
</properties>
3842

43+
<dependencies>
44+
<dependency>
45+
<groupId>com.google.googlejavaformat</groupId>
46+
<artifactId>google-java-format</artifactId>
47+
<version>${google-java-format.version}</version>
48+
<type>jar</type>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.google.guava</groupId>
52+
<artifactId>guava</artifactId>
53+
<version>${guava.version}</version>
54+
<type>jar</type>
55+
</dependency>
56+
</dependencies>
57+
3958
<repositories>
4059
<repository>
4160
<id>mars</id>
@@ -44,24 +63,35 @@
4463
</repository>
4564
</repositories>
4665

47-
<dependencies>
48-
<dependency>
49-
<groupId>com.google.googlejavaformat</groupId>
50-
<artifactId>google-java-format</artifactId>
51-
<version>1.6</version>
52-
</dependency>
53-
</dependencies>
54-
5566
<build>
5667
<plugins>
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-dependency-plugin</artifactId>
71+
<version>3.1.2</version>
72+
<executions>
73+
<execution>
74+
<id>copy-dependencies</id>
75+
<phase>initialize</phase>
76+
<goals>
77+
<goal>copy-dependencies</goal>
78+
</goals>
79+
</execution>
80+
</executions>
81+
<configuration>
82+
<outputDirectory>lib</outputDirectory>
83+
<includeScope>runtime</includeScope>
84+
<excludeTransitive>true</excludeTransitive>
85+
<overWriteSnapshots>true</overWriteSnapshots>
86+
</configuration>
87+
</plugin>
5788

5889
<plugin>
5990
<groupId>org.eclipse.tycho</groupId>
6091
<artifactId>tycho-maven-plugin</artifactId>
6192
<version>${tycho-version}</version>
6293
<extensions>true</extensions>
6394
</plugin>
64-
6595
<plugin>
6696
<groupId>org.eclipse.tycho</groupId>
6797
<artifactId>target-platform-configuration</artifactId>
@@ -97,7 +127,15 @@
97127
</configuration>
98128
</plugin>
99129

130+
<plugin>
131+
<groupId>org.apache.maven.plugins</groupId>
132+
<artifactId>maven-compiler-plugin</artifactId>
133+
<version>3.7.0</version>
134+
<configuration>
135+
<source>11</source>
136+
<target>11</target>
137+
</configuration>
138+
</plugin>
100139
</plugins>
101140
</build>
102-
103141
</project>

0 commit comments

Comments
 (0)