-
-
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.
Modeled Group + Version in BuildScript.
- Loading branch information
1 parent
9a5e87f
commit b86c125
Showing
5 changed files
with
50 additions
and
23 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
34 changes: 34 additions & 0 deletions
34
testkit/src/main/kotlin/com/autonomousapps/kit/gradle/GroupVersion.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.gradle | ||
|
||
import com.autonomousapps.kit.render.Element | ||
import com.autonomousapps.kit.render.Scribe | ||
|
||
public class GroupVersion( | ||
private val group: String? = null, | ||
private val version: String? = null, | ||
) : Element.Line { | ||
|
||
/** | ||
* Will return an empty string if both [group] and [version] are null. It is the responsibility of the caller to | ||
* handle this correctly. | ||
*/ | ||
override fun render(scribe: Scribe): String { | ||
if (group == null && version == null) return "" | ||
|
||
// TODO I feel like this is wanting an Element.MultiLine or something. | ||
var addLine = false | ||
return scribe.line { s -> | ||
group?.let { g -> | ||
addLine = true | ||
s.append("group = ") | ||
s.quoted(g) | ||
} | ||
version?.let { v -> | ||
if (addLine) s.appendLine() | ||
|
||
s.append("version = ") | ||
s.quoted(v) | ||
} | ||
} | ||
} | ||
} |
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