From 66c092564f4cdd22f1259aaeba541cb0d10ef3a7 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Tue, 23 Aug 2022 16:56:02 +0200 Subject: [PATCH] Fix addMainModuleInfo erroneously considered UP-TO-DATE The addMainModuleInfo task replaces the original JAR with a modifies JAR. However, previously it did not properly specify the task inputs, therefore it was erroneously considered UP-TO-DATE even if the JAR changed. Note that now unfortunately the `jar` task is always run and never considered UP-TO-DATE because addMainModuleInfo modified the original JAR. --- .../moditect/gradleplugin/add/AddMainModuleInfoTask.groovy | 3 ++- .../add/model/AbstractModuleConfiguration.groovy | 5 +++++ .../gradleplugin/add/model/ModuleConfiguration.groovy | 1 - .../groovy/org/moditect/gradleplugin/common/ModuleId.groovy | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/org/moditect/gradleplugin/add/AddMainModuleInfoTask.groovy b/src/main/groovy/org/moditect/gradleplugin/add/AddMainModuleInfoTask.groovy index 9689434..5b5de89 100644 --- a/src/main/groovy/org/moditect/gradleplugin/add/AddMainModuleInfoTask.groovy +++ b/src/main/groovy/org/moditect/gradleplugin/add/AddMainModuleInfoTask.groovy @@ -22,6 +22,7 @@ import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging import org.gradle.api.provider.Property import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Nested import org.gradle.api.tasks.Optional import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.WorkResult @@ -33,7 +34,7 @@ import org.moditect.gradleplugin.add.model.MainModuleConfiguration class AddMainModuleInfoTask extends AbstractAddModuleInfoTask { private static final Logger LOGGER = Logging.getLogger(AddMainModuleInfoTask) - @Input @Optional + @Nested @Optional final Property mainModule AddMainModuleInfoTask() { diff --git a/src/main/groovy/org/moditect/gradleplugin/add/model/AbstractModuleConfiguration.groovy b/src/main/groovy/org/moditect/gradleplugin/add/model/AbstractModuleConfiguration.groovy index bd44e5f..2af227b 100644 --- a/src/main/groovy/org/moditect/gradleplugin/add/model/AbstractModuleConfiguration.groovy +++ b/src/main/groovy/org/moditect/gradleplugin/add/model/AbstractModuleConfiguration.groovy @@ -21,6 +21,7 @@ import org.gradle.api.GradleException import org.gradle.api.Project import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Nested import org.gradle.api.tasks.Optional import org.gradle.api.tasks.PathSensitive import org.gradle.api.tasks.PathSensitivity @@ -44,9 +45,13 @@ abstract class AbstractModuleConfiguration { @Input @Optional String mainClass + @Input abstract String getShortName() + @InputFile abstract File getInputJar() + @Input abstract String getVersion() + @Nested abstract Set getOptionalDependencies() AbstractModuleConfiguration(Project project) { diff --git a/src/main/groovy/org/moditect/gradleplugin/add/model/ModuleConfiguration.groovy b/src/main/groovy/org/moditect/gradleplugin/add/model/ModuleConfiguration.groovy index efe4093..724488d 100644 --- a/src/main/groovy/org/moditect/gradleplugin/add/model/ModuleConfiguration.groovy +++ b/src/main/groovy/org/moditect/gradleplugin/add/model/ModuleConfiguration.groovy @@ -100,7 +100,6 @@ class ModuleConfiguration extends AbstractModuleConfiguration { primaryArtifact.file } - @Input @Override String getVersion() { primaryArtifact.moduleVersion.id.version diff --git a/src/main/groovy/org/moditect/gradleplugin/common/ModuleId.groovy b/src/main/groovy/org/moditect/gradleplugin/common/ModuleId.groovy index 65dd07b..d7a04fb 100644 --- a/src/main/groovy/org/moditect/gradleplugin/common/ModuleId.groovy +++ b/src/main/groovy/org/moditect/gradleplugin/common/ModuleId.groovy @@ -16,9 +16,12 @@ package org.moditect.gradleplugin.common import groovy.transform.Canonical +import org.gradle.api.tasks.Input @Canonical class ModuleId implements Serializable { + @Input String group + @Input String name }