-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push AbstractProject functionality into TestKit.
- Loading branch information
1 parent
56b69c3
commit 78c7490
Showing
7 changed files
with
39 additions
and
68 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
23 changes: 3 additions & 20 deletions
23
src/functionalTest/groovy/com/autonomousapps/AbstractProject.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 |
---|---|---|
@@ -1,36 +1,19 @@ | ||
package com.autonomousapps | ||
|
||
import com.autonomousapps.kit.AbstractGradleProject | ||
import com.autonomousapps.kit.GradleProject | ||
import com.autonomousapps.kit.gradle.Plugin | ||
|
||
@SuppressWarnings('GrMethodMayBeStatic') | ||
abstract class AbstractProject { | ||
abstract class AbstractProject extends AbstractGradleProject { | ||
|
||
private String className = getClass().simpleName | ||
protected final androidAppPlugin = [Plugin.androidAppPlugin] | ||
protected final androidLibPlugin = [Plugin.androidLibPlugin] | ||
|
||
protected GradleProject.Builder newGradleProjectBuilder() { | ||
return new GradleProject.Builder(defaultFile(), GradleProject.DslKind.GROOVY) | ||
} | ||
|
||
protected GradleProject.Builder minimalAndroidProjectBuilder(String agpVersion) { | ||
return GradleProject.minimalAndroidProject( | ||
defaultFile(), | ||
rootDir.toFile(), | ||
agpVersion | ||
) | ||
} | ||
|
||
private File defaultFile() { | ||
return new File("build/functionalTest/${newSlug()}") | ||
} | ||
|
||
// Very similar to what is in RootProject | ||
private String newSlug() { | ||
def worker = System.getProperty('org.gradle.test.worker') ?: '' | ||
if (!worker.isEmpty()) { | ||
worker = "-$worker" | ||
} | ||
return "$className-${UUID.randomUUID().toString().take(16)}$worker" | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
testkit/src/main/kotlin/com/autonomousapps/kit/AbstractGradleProject.kt
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,34 @@ | ||
package com.autonomousapps.kit | ||
|
||
import java.io.File | ||
import java.nio.file.Path | ||
import java.util.UUID | ||
import kotlin.io.path.createDirectories | ||
|
||
/** | ||
* Provides some common functionality for Gradle functional tests. | ||
*/ | ||
public abstract class AbstractGradleProject @JvmOverloads constructor( | ||
buildPath: String = "build/functionalTest", | ||
) { | ||
|
||
protected fun newGradleProjectBuilder(): GradleProject.Builder { | ||
return GradleProject.Builder(rootDir.toFile(), GradleProject.DslKind.GROOVY) | ||
} | ||
|
||
/** | ||
* The root directory of a Gradle build. The default value is | ||
* ``` | ||
* <PWD>/build/functionalTest/<ConcreteClassSimpleName>-<UUID>[-Gradle worker ID (if present)] | ||
* ``` | ||
*/ | ||
public val rootDir: Path = File("$buildPath/${newSlug()}").toPath().createDirectories() | ||
|
||
private fun newSlug(): String { | ||
var worker = System.getProperty("org.gradle.test.worker", "") | ||
if (worker.isNotEmpty()) { | ||
worker = "-$worker" | ||
} | ||
return "${javaClass.simpleName}-${UUID.randomUUID().toString().take(8)}$worker" | ||
} | ||
} |