-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Unity Test task inputs weren't taking as input anything related to the project file structure, so it ended up being up-to-date even when there were relevant changes to the project. the `inputFiles` Input was create on the task in order to resolve this. ## Changes * ![FIX] Test task being up-to-date in wrong situations
- Loading branch information
1 parent
9ad3429
commit 384823e
Showing
6 changed files
with
211 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/groovy/wooga/gradle/unity/internal/InputFileTreeFactory.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package wooga.gradle.unity.internal | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.file.ConfigurableFileCollection | ||
import org.gradle.api.file.Directory | ||
import org.gradle.api.file.FileTreeElement | ||
import org.gradle.api.provider.Provider | ||
import wooga.gradle.unity.UnityPluginExtension | ||
import wooga.gradle.unity.UnityTask | ||
|
||
class InputFileTreeFactory { | ||
|
||
private final Project project | ||
private final UnityPluginExtension extension | ||
|
||
InputFileTreeFactory(Project project, UnityPluginExtension extension) { | ||
this.project = project | ||
this.extension = extension | ||
} | ||
|
||
static ConfigurableFileCollection inputFilesForUnityTask(Project project, UnityPluginExtension extension, UnityTask task) { | ||
return new InputFileTreeFactory(project, extension).inputFilesForUnityTask(task) | ||
} | ||
|
||
ConfigurableFileCollection inputFilesForBuildTarget(Provider<Directory> projectDirectory, Provider<String> buildTarget) { | ||
def assetsDir = extension.assetsDir | ||
def assetsFileTree = project.fileTree(assetsDir) | ||
assetsFileTree.include { FileTreeElement elem -> | ||
def path = elem.getRelativePath().getPathString().toLowerCase() | ||
def name = elem.name.toLowerCase() | ||
if (path.contains("plugins") && !((name == "plugins") || (name == "plugins.meta"))) { | ||
return isPluginElemFromBuildTarget(elem, buildTarget) | ||
} else { | ||
return true | ||
} | ||
} | ||
|
||
def projectSettingsDir = projectDirectory.map {it.dir("ProjectSettings") } | ||
def projectSettingsFileTree = project.fileTree(projectSettingsDir) | ||
|
||
def packageManagerDir = projectDirectory.map{it.dir("UnityPackageManager") } | ||
def packageManagerDirFileTree = project.fileTree(packageManagerDir) | ||
|
||
return project.files(assetsFileTree, projectSettingsFileTree, packageManagerDirFileTree) | ||
} | ||
|
||
ConfigurableFileCollection inputFilesForUnityTask(UnityTask unityTask) { | ||
return inputFilesForBuildTarget(unityTask.projectDirectory, unityTask.buildTarget) | ||
} | ||
|
||
private static boolean isPluginElemFromBuildTarget(FileTreeElement element, Provider<String> buildTarget) { | ||
/* | ||
Why can we use / here? Because {@code element} is a {@code FileTreeElement} object. | ||
The getPath() method is not the same as {@code File.getPath()} | ||
From the docs: | ||
* Returns the path of this file, relative to the root of the containing file tree. Always uses '/' as the hierarchy | ||
* separator, regardless of platform file separator. Same as calling <code>getRelativePath().getPathString()</code>. | ||
* | ||
* @return The path. Never returns null. | ||
*/ | ||
def path = element.getRelativePath().getPathString().toLowerCase() | ||
if (buildTarget.isPresent()) { | ||
return path.contains("plugins/" + buildTarget.get()) | ||
} else { | ||
return true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters