mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Use kotlin_module not kotlin-module to identify Kotlin module metadata
See gh-16004
This commit is contained in:
parent
91a005f578
commit
cb6362df82
@ -381,7 +381,7 @@ public class Repackager {
|
|||||||
}
|
}
|
||||||
if ((entry.getName().startsWith("META-INF/")
|
if ((entry.getName().startsWith("META-INF/")
|
||||||
&& !entry.getName().equals("META-INF/aop.xml")
|
&& !entry.getName().equals("META-INF/aop.xml")
|
||||||
&& !entry.getName().endsWith(".kotlin-module"))
|
&& !entry.getName().endsWith(".kotlin_module"))
|
||||||
|| entry.getName().startsWith("BOOT-INF/")
|
|| entry.getName().startsWith("BOOT-INF/")
|
||||||
|| entry.getName().equals("module-info.class")) {
|
|| entry.getName().equals("module-info.class")) {
|
||||||
return entry;
|
return entry;
|
||||||
|
@ -679,15 +679,15 @@ public class RepackagerTests {
|
|||||||
public void kotlinModuleMetadataMovesBeneathBootInfClassesWhenRepackaged()
|
public void kotlinModuleMetadataMovesBeneathBootInfClassesWhenRepackaged()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
|
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
|
||||||
this.testJarFile.addFile("META-INF/test.kotlin-module",
|
this.testJarFile.addFile("META-INF/test.kotlin_module",
|
||||||
this.temporaryFolder.newFile("test.kotlin-module"));
|
this.temporaryFolder.newFile("test.kotlin_module"));
|
||||||
File source = this.testJarFile.getFile();
|
File source = this.testJarFile.getFile();
|
||||||
File dest = this.temporaryFolder.newFile("dest.jar");
|
File dest = this.temporaryFolder.newFile("dest.jar");
|
||||||
Repackager repackager = new Repackager(source);
|
Repackager repackager = new Repackager(source);
|
||||||
repackager.repackage(dest, NO_LIBRARIES);
|
repackager.repackage(dest, NO_LIBRARIES);
|
||||||
try (JarFile jarFile = new JarFile(dest)) {
|
try (JarFile jarFile = new JarFile(dest)) {
|
||||||
assertThat(jarFile.getEntry("META-INF/test.kotlin-module")).isNull();
|
assertThat(jarFile.getEntry("META-INF/test.kotlin_module")).isNull();
|
||||||
assertThat(jarFile.getEntry("BOOT-INF/classes/META-INF/test.kotlin-module"))
|
assertThat(jarFile.getEntry("BOOT-INF/classes/META-INF/test.kotlin_module"))
|
||||||
.isNotNull();
|
.isNotNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.springframework.boot.maven.it</groupId>
|
||||||
|
<artifactId>jar-with-kotlin-module</artifactId>
|
||||||
|
<version>0.0.1.BUILD-SNAPSHOT</version>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>@java.version@</maven.compiler.source>
|
||||||
|
<maven.compiler.target>@java.version@</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||||
|
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>@project.groupId@</groupId>
|
||||||
|
<artifactId>@project.artifactId@</artifactId>
|
||||||
|
<version>@project.version@</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<requiresUnpack>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-compiler</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</requiresUnpack>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>@maven-jar-plugin.version@</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifestEntries>
|
||||||
|
<Not-Used>Foo</Not-Used>
|
||||||
|
</manifestEntries>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>@kotlin.version@</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>process-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>process-test-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
<version>@spring.version@</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>@servlet-api.version@</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>@log4j2.version@</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>@kotlin.version@</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-reflect</artifactId>
|
||||||
|
<version>@kotlin.version@</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-compiler</artifactId>
|
||||||
|
<version>@kotlin.version@</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:JvmName("SampleApplication")
|
||||||
|
package org.test;
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import org.springframework.boot.maven.*;
|
||||||
|
|
||||||
|
File f = new File( basedir, "target/jar-with-kotlin-module-0.0.1.BUILD-SNAPSHOT.jar");
|
||||||
|
new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) {
|
||||||
|
@Override
|
||||||
|
protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception {
|
||||||
|
super.verifyZipEntries(verifier)
|
||||||
|
verifier.assertHasEntryNameStartingWith("BOOT-INF/classes/META-INF/jar-with-kotlin-module.kotlin_module")
|
||||||
|
verifier.assertHasUnpackEntry("BOOT-INF/lib/kotlin-compiler-")
|
||||||
|
verifier.assertHasNonUnpackEntry("BOOT-INF/lib/kotlin-stdlib-")
|
||||||
|
verifier.assertHasNonUnpackEntry("BOOT-INF/lib/kotlin-reflect-")
|
||||||
|
}
|
||||||
|
}.verify();
|
Loading…
Reference in New Issue
Block a user