Skip to content

Commit

Permalink
Extend test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Jul 15, 2024
1 parent 04be518 commit 3e93a5f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import javax.inject.Inject;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -77,7 +78,8 @@ public ModuleInfo put(File projectRoot, String moduleInfoPath, String artifact,
if (maybePutModuleInfo(folder, providers)) {
ModuleInfo thisModuleInfo = moduleInfo.get(folder);
moduleNameToProjectPath.put(thisModuleInfo.getModuleName(), ":" + artifact);
String capabilitySuffix = sourceSetToCapabilitySuffix(Paths.get(moduleInfoPath).getParent().getFileName().toString());
Path parentDirectory = Paths.get(moduleInfoPath).getParent();
String capabilitySuffix = parentDirectory == null ? null : sourceSetToCapabilitySuffix(parentDirectory.getFileName().toString());
if (capabilitySuffix != null) {
if (group.isPresent()) {
moduleNameToCapability.put(thisModuleInfo.getModuleName(), group.get() + ":" + artifact + "-" + capabilitySuffix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class SettingsPluginTest extends Specification {
settingsFile << '''
javaModules {
module("app") { plugin("application") }
module("lib") { plugin("java-library") }
module("lib") {
plugin("java-library")
artifact = "lib-x"
}
}
'''
libModuleInfoFile << 'module abc.lib { }'
Expand All @@ -39,7 +42,7 @@ class SettingsPluginTest extends Specification {

then:
result.task(":app:compileJava").outcome == SUCCESS
result.task(":lib:compileJava").outcome == SUCCESS
result.task(":lib-x:compileJava").outcome == SUCCESS
}

def "finds all modules in a directory"() {
Expand Down Expand Up @@ -135,4 +138,31 @@ class SettingsPluginTest extends Specification {
result.task(":compileJava").outcome == NO_SOURCE
}

def 'can have module-info in custom location'() {
given:
settingsFile << '''
javaModules {
module("app") { plugin("application") }
module("lib") {
plugin("java-library")
moduleInfoPaths.add("src")
}
}
'''
libBuildFile << 'sourceSets.main { java.setSrcDirs(listOf("src")) }'
file("lib/src/module-info.java") << 'module abc.lib { }'
appModuleInfoFile << '''
module org.gradlex.test.app {
requires abc.lib;
}
'''

when:
def result = runner(':app:compileJava').build()

then:
result.task(":app:compileJava").outcome == SUCCESS
result.task(":lib:compileJava").outcome == SUCCESS
}

}

0 comments on commit 3e93a5f

Please sign in to comment.