Skip to content

Commit

Permalink
Rename, relocate and skip module name checks
Browse files Browse the repository at this point in the history
- Treat junit-jupiter-migration-support vs junit-jupiter-migrationsupport
as as a special case.
- Move shadowed joptsimple to org.junit.platform.console.shadow.joptsimple
- Move shadowed com.univocity to org.junit.jupiter.params.shadow.com.univocity
- Remove AutomaticModuleName from standalone JAR
  • Loading branch information
sormuras committed Jun 7, 2017
1 parent a2ec645 commit 1d8c684
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
3 changes: 1 addition & 2 deletions documentation/src/docs/asciidoc/release-notes-5.0.0-M5.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ is placed on the Java 9 module path.

| `junit-jupiter-api-<VERSION>.jar` | `org.junit.jupiter.api`
| `junit-jupiter-engine-<VERSION>.jar` | `org.junit.jupiter.engine`
| `junit-jupiter-migration-support-<VERSION>.jar` | `org.junit.jupiter.migration.support`
| `junit-jupiter-migration-support-<VERSION>.jar` | `org.junit.jupiter.migrationsupport`
| `junit-jupiter-params-<VERSION>.jar` | `org.junit.jupiter.params`
| `junit-platform-commons-<VERSION>.jar` | `org.junit.platform.commons`
| `junit-platform-console-<VERSION>.jar` | `org.junit.platform.console`
| `junit-platform-console-standalone-<VERSION>.jar` | `org.junit.platform.console.standalone`
| `junit-platform-engine-<VERSION>.jar` | `org.junit.platform.engine`
| `junit-platform-gradle-plugin-<VERSION>.jar` | `org.junit.platform.gradle.plugin`
| `junit-platform-launcher-<VERSION>.jar` | `org.junit.platform.launcher`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies {
jar {
manifest {
attributes(
'Automatic-Module-Name': 'org.junit.jupiter.migration.support'
'Automatic-Module-Name': 'org.junit.jupiter.migrationsupport'
)
}
}
2 changes: 1 addition & 1 deletion junit-jupiter-params/junit-jupiter-params.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ shadowJar {
classifier = null
configurations = [project.configurations.shadow]
exclude 'META-INF/**'
relocate 'com.univocity', 'org.junit.jupiter.params.com.univocity'
relocate 'com.univocity', 'org.junit.jupiter.params.shadow.com.univocity'
from(projectDir) {
include 'LICENSE-univocity-parsers.md'
into 'META-INF'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ sourceSets.main.compileClasspath += configurations.shadow

jar {
manifest {
// Note: do not add `'Automatic-Module-Name': ...` because this artifact is not
// meant to be used on the Java 9 module path.
// See https://github.com/junit-team/junit5/issues/866#issuecomment-306017162
attributes(
'Main-Class': 'org.junit.platform.console.ConsoleLauncher',
'Automatic-Module-Name': 'org.junit.platform.console.standalone'
'Main-Class': 'org.junit.platform.console.ConsoleLauncher'
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions junit-platform-console/junit-platform-console.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ shadowJar {
classifier = null
configurations = [project.configurations.shadow]
exclude 'META-INF/**'
relocate 'joptsimple', 'org.junit.platform.joptsimple'
relocate 'joptsimple', 'org.junit.platform.console.shadow.joptsimple'
transform(com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer) {
paths = [
'joptsimple/ExceptionMessages.properties',
'joptsimple/HelpFormatterMessages.properties'
]
keyTransformer = { key ->
key.replaceAll('^(joptsimple\\..*)$', 'org.junit.platform.$1')
key.replaceAll('^(joptsimple\\..*)$', 'org.junit.platform.console.shadow.$1')
}
}
from(projectDir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
Expand All @@ -26,7 +27,6 @@
import java.util.stream.Stream;
import java.util.zip.ZipEntry;

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand Down Expand Up @@ -66,6 +66,7 @@ static Stream<String> moduleDirectoryNames() throws IOException {
.filter(Files::isDirectory)
.map(Path::getFileName)
.map(Object::toString)
.filter(name -> !name.equals("junit-platform-console-standalone"))
.filter(name -> name.startsWith("junit-"));
// @formatter:on
}
Expand All @@ -74,6 +75,9 @@ static Stream<String> moduleDirectoryNames() throws IOException {
@MethodSource("moduleDirectoryNames")
void automaticModuleName(String module) {
String expected = "org." + module.replace('-', '.');
if (module.equals("junit-jupiter-migration-support")) {
expected = "org.junit.jupiter.migrationsupport";
}
String jarName = module + "-" + version(module) + ".jar";
Path jarPath = Paths.get("..", module).resolve("build/libs").resolve(jarName).normalize();
try (JarFile jarFile = new JarFile(jarPath.toFile())) {
Expand All @@ -89,13 +93,10 @@ void automaticModuleName(String module) {
jarFile.stream()
.map(ZipEntry::getName)
.filter(n -> n.endsWith(".class"))
.filter(n -> !n.startsWith(expectedStartOfPackageName)).
forEach(unexpectedNames::add);
.filter(n -> !n.startsWith(expectedStartOfPackageName))
.forEach(unexpectedNames::add);
// @formatter:on
if (unexpectedNames.isEmpty()) {
return;
}
Assumptions.assumeTrue(unexpectedNames.isEmpty(), unexpectedNames.size()
assertTrue(unexpectedNames.isEmpty(), unexpectedNames.size()
+ " entries are not located in (a sub-) package of " + expectedStartOfPackageName);
}
catch (IOException e) {
Expand Down

0 comments on commit 1d8c684

Please sign in to comment.