Skip to content

Commit

Permalink
issue #93: add mergedModuleJarVersion property
Browse files Browse the repository at this point in the history
  • Loading branch information
siordache committed Oct 16, 2019
1 parent 257431c commit 08ed301
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
21 changes: 15 additions & 6 deletions src/main/groovy/org/beryx/jlink/CreateMergedModuleTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.beryx.jlink.data.JdepsUsage
import org.beryx.jlink.data.ModuleInfo
import org.beryx.jlink.impl.CreateMergedModuleTaskImpl
import org.beryx.jlink.util.PathUtil
import org.beryx.jlink.util.Util
import org.gradle.api.Project
import org.gradle.api.file.Directory
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
Expand All @@ -48,7 +48,14 @@ class CreateMergedModuleTask extends BaseTask {

@Input
String getMergedModuleJarName() {
extension.mergedModuleJarName.get()
String jarName = extension.mergedModuleJarName.get()
if(jarName.endsWith('.jar')) jarName = jarName[0 .. -5]
jarName
}

@Input
String getMergedModuleJarVersion() {
extension.mergedModuleJarVersion.get()
}

@InputDirectory
Expand Down Expand Up @@ -77,9 +84,13 @@ class CreateMergedModuleTask extends BaseTask {
}

@OutputFile
@CompileDynamic
File getMergedModuleJar() {
new File(PathUtil.getJlinkJarsDirPath(jlinkBasePath), mergedModuleJarName)
String jarFileName = mergedModuleJarName
if(mergedModuleJarVersion && mergedModuleJarVersion != Project.DEFAULT_VERSION) {
jarFileName += "-$mergedModuleJarVersion"
}
jarFileName += ".jar"
new File(PathUtil.getJlinkJarsDirPath(jlinkBasePath), jarFileName)
}

CreateMergedModuleTask() {
Expand All @@ -94,15 +105,13 @@ class CreateMergedModuleTask extends BaseTask {
taskData.forceMergedJarPrefixes = forceMergedJarPrefixes
taskData.extraDependenciesPrefixes = extraDependenciesPrefixes
taskData.mergedModuleName = mergedModuleName
taskData.mergedModuleJarName = mergedModuleJarName
taskData.mergedModuleInfo = mergedModuleInfo
taskData.useJdeps = useJdeps
taskData.mergedModuleJar = mergedModuleJar
taskData.mergedJarsDir = mergedJarsDir.asFile
taskData.javaHome = javaHome
taskData.configuration = project.configurations.getByName(configuration)

taskData.nonModularJarsDirPath = PathUtil.getNonModularJarsDirPath(taskData.jlinkBasePath)
taskData.jlinkJarsDirPath = PathUtil.getJlinkJarsDirPath(taskData.jlinkBasePath)
taskData.tmpMergedModuleDirPath = PathUtil.getTmpMergedModuleDirPath(taskData.jlinkBasePath)
taskData.tmpModuleInfoDirPath = PathUtil.getTmpModuleInfoDirPath(taskData.jlinkBasePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ class CreateMergedModuleTaskData extends BaseTaskData {
List<String> forceMergedJarPrefixes
List<String> extraDependenciesPrefixes
String mergedModuleName
String mergedModuleJarName
ModuleInfo mergedModuleInfo
JdepsUsage useJdeps
File mergedJarsDir
String javaHome
Configuration configuration

File mergedModuleJar
String nonModularJarsDirPath
String jlinkJarsDirPath
String tmpMergedModuleDirPath
String tmpModuleInfoDirPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class JlinkPluginExtension {
final Property<String> moduleName
final Property<String> mergedModuleName
final Property<String> mergedModuleJarName
final Property<String> mergedModuleJarVersion

final Property<LauncherData> launcherData
final ListProperty<SecondaryLauncherData> secondaryLaunchers
Expand Down Expand Up @@ -78,6 +79,9 @@ class JlinkPluginExtension {
mergedModuleJarName = project.objects.property(String)
mergedModuleJarName.set(project.provider{"${Util.getArchiveBaseName(project)}.merged.module.jar" as String})

mergedModuleJarVersion = project.objects.property(String)
mergedModuleJarVersion.set(project.provider{project.version as String})

launcherData = project.objects.property(LauncherData)
def ld = new LauncherData()
ld.name = project.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CreateMergedModuleTaskImpl extends BaseTaskImpl<CreateMergedModuleTaskData

@CompileDynamic
void execute() {
def jarFilePath = "$td.tmpMergedModuleDirPath/$td.mergedModuleJarName"
def jarFilePath = "$td.tmpMergedModuleDirPath/$td.mergedModuleJar.name"
Util.createJar(project, td.javaHome, jarFilePath, td.mergedJarsDir)
def modInfoDir = genModuleInfo(project.file(jarFilePath), project.file(td.tmpJarsDirPath), td.mergedModuleName)
compileModuleInfo(project.file(modInfoDir), project.file(jarFilePath), project.file(td.tmpModuleInfoDirPath))
Expand Down
2 changes: 1 addition & 1 deletion src/test/groovy/org/beryx/jlink/JlinkPluginSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class JlinkPluginSpec extends Specification {
File buildFile = setUpBuild('local-deps')
BuildResult result = GradleRunner.create()
.withDebug(true)
.withGradleVersion('5.2')
.withGradleVersion('5.6.2')
.withProjectDir(testProjectDir.root)
.withPluginClasspath()
.withArguments(JlinkPlugin.TASK_NAME_JLINK, "-is")
Expand Down

0 comments on commit 08ed301

Please sign in to comment.