-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
69 additions
and
1 deletion.
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
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/app/revanced/patcher/annotation/SincePatcher.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,13 @@ | ||
package app.revanced.patcher.annotation | ||
|
||
import app.revanced.patcher.patch.Patch | ||
import app.revanced.patcher.Patcher | ||
|
||
/** | ||
* Declares a [Patch] deprecated for removal. | ||
* @param version The minimum version of the [Patcher] this [Patch] supports. | ||
*/ | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@MustBeDocumented | ||
annotation class SincePatcher(val version: String) |
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
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/app/revanced/patcher/util/VersionReader.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,18 @@ | ||
package app.revanced.patcher.util | ||
|
||
import java.util.* | ||
|
||
internal object VersionReader { | ||
@JvmStatic | ||
private val props = Properties().apply { | ||
load( | ||
VersionReader::class.java.getResourceAsStream("/revanced-patcher/version.properties") | ||
?: throw IllegalStateException("Could not load version.properties") | ||
) | ||
} | ||
|
||
@JvmStatic | ||
fun read(): String { | ||
return props.getProperty("version") ?: throw IllegalStateException("Version not found") | ||
} | ||
} |
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 @@ | ||
version=${projectVersion} |
20 changes: 20 additions & 0 deletions
20
src/test/kotlin/app/revanced/patcher/util/VersionReaderTest.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,20 @@ | ||
package app.revanced.patcher.util | ||
|
||
import org.junit.jupiter.api.Test | ||
|
||
import org.junit.jupiter.api.Assertions.* | ||
|
||
internal class VersionReaderTest { | ||
@Test | ||
fun read() { | ||
val version = VersionReader.read() | ||
assertNotNull(version) | ||
assertTrue(version.isNotEmpty()) | ||
val parts = version.split(".") | ||
assertEquals(3, parts.size) | ||
parts.forEach { | ||
assertTrue(it.toInt() >= 0) | ||
} | ||
println(version) | ||
} | ||
} |