Skip to content

Commit fac8ce5

Browse files
committed
Create shaded jar with kotlin compiler embeddable
1 parent f4faabf commit fac8ce5

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/.project
33
/.settings/
44
/target/
5+
dependency-reduced-pom.xml

pom.xml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,14 @@ Wisconsin-Madison.</license.copyrightOwners>
8888
<!-- NB: Work around duplicate classes issue in Kotlin dependencies-->
8989
<allowedDuplicateClasses>org/jetbrains/kotlin/daemon/common/*,kotlinx/coroutines/**</allowedDuplicateClasses>
9090
<kotlin.version>1.4.30</kotlin.version>
91-
<!-- NB: Have to disable manifest-only jar ot be able to run tests on command line. -->
91+
<!-- NB: We have to disable manifest-only jar ot be able to run tests on command line. -->
9292
<!-- NB: Tests work in IntelliJ but manifest-only jar seems to mess with it on command line. -->
9393
<!-- NB: cf: mvn surefire:help -Ddetail=true -->
9494
<surefire.useManifestOnlyJar>false</surefire.useManifestOnlyJar>
95+
96+
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
97+
98+
<kotlin-compiler-embeddable.optional>false</kotlin-compiler-embeddable.optional>
9599
</properties>
96100

97101
<repositories>
@@ -113,6 +117,7 @@ Wisconsin-Madison.</license.copyrightOwners>
113117
<groupId>org.jetbrains.kotlin</groupId>
114118
<artifactId>kotlin-compiler-embeddable</artifactId>
115119
<version>${kotlin.version}</version>
120+
<optional>${kotlin-compiler-embeddable.optional}</optional>
116121
</dependency>
117122
<dependency>
118123
<groupId>org.jetbrains.kotlin</groupId>
@@ -138,4 +143,54 @@ Wisconsin-Madison.</license.copyrightOwners>
138143
<scope>test</scope>
139144
</dependency>
140145
</dependencies>
146+
147+
<profiles>
148+
<profile>
149+
<!-- The JetBrains trove4j fork clashes with the gnu trove4j jar in Fiji.
150+
We need to shade and relocate in this case. -->
151+
<id>shade-trove4j-fork</id>
152+
<activation>
153+
<property>
154+
<name>scijava.app.directory</name>
155+
</property>
156+
</activation>
157+
<properties>
158+
<kotlin-compiler-embeddable.optional>true</kotlin-compiler-embeddable.optional>
159+
</properties>
160+
<build>
161+
<plugins>
162+
<plugin>
163+
<groupId>org.apache.maven.plugins</groupId>
164+
<artifactId>maven-shade-plugin</artifactId>
165+
<version>${maven-shade-plugin.version}</version>
166+
<executions>
167+
<execution>
168+
<phase>package</phase>
169+
<goals>
170+
<goal>shade</goal>
171+
</goals>
172+
<configuration>
173+
<artifactSet>
174+
<includes>
175+
<include>org.jetbrains.intellij.deps:trove4j</include>
176+
<include>org.jetbrains.kotlin:kotlin-compiler-embeddable</include>
177+
<include>org.jetbrains.kotlin:kotlin-script-runtime</include>
178+
<include>org.jetbrains.kotlin:kotlin-reflect</include>
179+
<include>org.jetbrains.kotlin:kotlin-daemon-embeddable</include>
180+
</includes>
181+
</artifactSet>
182+
<relocations>
183+
<relocation>
184+
<pattern>gnu.trove</pattern>
185+
<shadedPattern>gnu.trove.shaded</shadedPattern>
186+
</relocation>
187+
</relocations>
188+
</configuration>
189+
</execution>
190+
</executions>
191+
</plugin>
192+
</plugins>
193+
</build>
194+
</profile>
195+
</profiles>
141196
</project>

0 commit comments

Comments
 (0)