diff --git a/src/main/groovy/wooga/gradle/unity/UnityPlugin.groovy b/src/main/groovy/wooga/gradle/unity/UnityPlugin.groovy index b7f0e06c..bb403072 100644 --- a/src/main/groovy/wooga/gradle/unity/UnityPlugin.groovy +++ b/src/main/groovy/wooga/gradle/unity/UnityPlugin.groovy @@ -40,6 +40,7 @@ import wooga.gradle.unity.tasks.Activate import wooga.gradle.unity.tasks.ReturnLicense import wooga.gradle.unity.tasks.Test import wooga.gradle.unity.tasks.UnityPackage +import wooga.gradle.unity.tasks.UnityPackageArtifact import wooga.gradle.unity.tasks.internal.AbstractUnityProjectTask import wooga.gradle.unity.tasks.internal.AbstractUnityTask @@ -121,11 +122,11 @@ class UnityPlugin implements Plugin { final BasePluginConvention basePluginConvention = new BasePluginConvention(project) configureUnityExtensionConvention(project, unityExtension) + createUnityPackageConfiguration(project) configureUnityTasks(project, unityExtension) addTestTasks(project, unityExtension) addPackageTask(project) addActivateAndReturnLicenseTasks(project, unityExtension) - createUnityPackageConfiguration(project) addDefaultReportTasks(project, unityExtension) configureArchiveDefaults(project, basePluginConvention) @@ -242,6 +243,7 @@ class UnityPlugin implements Plugin { } private static void configureArchiveDefaults(final Project project, final BasePluginConvention pluginConvention) { + def configuration = project.configurations.getByName(UNITY_PACKAGE_CONFIGURATION_NAME) project.getTasks().withType(UnityPackage.class, new Action() { void execute(UnityPackage task) { ConventionMapping taskConventionMapping = task.getConventionMapping() @@ -265,7 +267,8 @@ class UnityPlugin implements Plugin { } }) - project.artifacts.add(UNITY_PACKAGE_CONFIGURATION_NAME, [file: task.archivePath, builtBy: task]) + UnityPackageArtifact artifact = UnityPackageArtifact.fromTask(task) + configuration.getArtifacts().add(artifact) } }) } diff --git a/src/main/groovy/wooga/gradle/unity/tasks/UnityPackageArtifact.groovy b/src/main/groovy/wooga/gradle/unity/tasks/UnityPackageArtifact.groovy new file mode 100644 index 00000000..e5059192 --- /dev/null +++ b/src/main/groovy/wooga/gradle/unity/tasks/UnityPackageArtifact.groovy @@ -0,0 +1,58 @@ +package wooga.gradle.unity.tasks + +import org.gradle.api.artifacts.PublishArtifact +import org.gradle.api.internal.tasks.DefaultTaskDependency +import org.gradle.api.internal.tasks.TaskResolver +import org.gradle.api.tasks.TaskDependency + +class UnityPackageArtifact implements PublishArtifact { + + + @Override + String getName() { + return task.getArchiveName().split(".${UnityPackage.UNITY_PACKAGE_EXTENSION}")[0] + } + + @Override + String getExtension() { + return UnityPackage.UNITY_PACKAGE_EXTENSION + } + + @Override + String getType() { + return "zip" + } + + @Override + String getClassifier() { + return null + } + + @Override + File getFile() { + return this.task.getArchivePath() + } + + @Override + Date getDate() { + return null + } + + def taskDependency + + @Override + TaskDependency getBuildDependencies() { + taskDependency + } + private UnityPackage task + + static PublishArtifact fromTask(UnityPackage task) { + new UnityPackageArtifact(task) + } + + UnityPackageArtifact(UnityPackage task) { + this.task = task + taskDependency = new DefaultTaskDependency(task.project.tasks as TaskResolver) + taskDependency.add(task) + } +}