Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #244 secondary launcher fails in Kotlin DSL #257

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class JlinkPluginExtension {
action.execute(launcherData.get())
}

void secondaryLauncher(Action<LauncherData> action) {
void secondaryLauncher(Action<SecondaryLauncherData> action) {
def ld = new SecondaryLauncherData(null)
ld.moduleName = moduleName.get()
Util.addToListProperty(secondaryLaunchers, ld)
Expand Down
18 changes: 18 additions & 0 deletions src/test/groovy/org/beryx/jlink/JlinkPluginSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,24 @@ class JlinkPluginSpec extends Specification {
checkOutput(result, 'howdy', 'Howdy!')
}

def "should create image of project with multiple launchers using kotlin DSL"() {
when:

File buildFile = setUpBuild('multi-launch-kotlin-dsl')
BuildResult result = GradleRunner.create()
.withDebug(true)
.withGradleVersion('7.6')
.withProjectDir(testProjectDir.toFile())
.withPluginClasspath()
.withArguments(JlinkPlugin.TASK_NAME_JLINK, "-is")
.build();

then:
checkOutput(result, 'hello', 'Hello, world!')
checkOutput(result, 'helloAgain', 'Hello again!')
checkOutput(result, 'howdy', 'Howdy!')
}

private boolean checkOutput(BuildResult result, String imageName, String expectedOutput) {
def imageBinDir = new File(testProjectDir.toFile(), 'build/image/bin')
def launcherExt = OperatingSystem.current.windows ? '.bat' : ''
Expand Down
35 changes: 35 additions & 0 deletions src/test/resources/multi-launch-kotlin-dsl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
plugins {
id("org.javamodularity.moduleplugin") version "1.8.12"
id("org.beryx.jlink")
}

repositories {
mavenCentral()
}

extra["moduleName"] = "org.example.multi"

application {
mainClass.set("org.example.multi.Hello")
}

jlink {
launcher {
name = "hello"
noConsole = false
jvmArgs = listOf(
"-Xms512m",
"-Xmx4g",
"-XX:+UseShenandoahGC"
)
}
secondaryLauncher {
name = "helloAgain"
mainClass = "org.example.multi.HelloAgain"
}
secondaryLauncher {
name = "howdy"
moduleName= "org.example.multi"
mainClass = "org.example.multi.Howdy"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "multi-launch-kotlin-dsl"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module org.example.multi {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.example.multi;

public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.example.multi;

public class HelloAgain {
public static void main(String[] args) {
System.out.println("Hello again!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.example.multi;

public class Howdy {
public static void main(String[] args) {
System.out.println("Howdy!");
}
}
Loading