Skip to content

Commit

Permalink
Merge 497dd51 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 23, 2022
2 parents 69725a8 + 497dd51 commit 78f70a7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
]
jdk-version: [
8,
18
19
]
gradle-version: [
'7.5.1',
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@master
with:
java-version: 17
java-version: 8
distribution: 'temurin'
cache: gradle
- name: Build uber jar
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "io.github.rtmigo"
version = "0.4.3" // -SNAPSHOT
version = "0.5.0" // -SNAPSHOT

repositories {
mavenCentral()
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/Build.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT EDIT. Generated by Gradle task "generateBuildKt"
object Build {
const val version = "0.4.1"
const val date = "2022-10-22"
const val version = "0.4.3"
const val date = "2022-10-23"
}
27 changes: 26 additions & 1 deletion src/main/kotlin/maven/PomParsing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package maven

import org.jsoup.Jsoup
import tools.*


data class PomXml(val xml: String) {
Expand All @@ -30,7 +31,7 @@ data class PomXml(val xml: String) {
check(items.size >= 1)
check(items.all { it.text().isNotBlank() })
} catch (e: Throwable) {
throw Exception("POM problem with item '$selector'.", e)
throw Exception("POM error: item '$selector'.", e)
}

fun validate() {
Expand All @@ -56,8 +57,32 @@ data class PomXml(val xml: String) {
requireAtLeastOne("project > licenses > license > url")
requireAtLeastOne("project > developers > developer > name")
requireAtLeastOne("project > developers > developer > email")



val pomJavaVersion = this.javaVersion()
val runningJavaVersion = jriVersion()

if (pomJavaVersion<runningJavaVersion) {
// TODO unit test
throw Exception("Currently running Java version is $runningJavaVersion, but " +
"<java.version/> in POM is $pomJavaVersion. " +
"Either compile with older Java or change the " +
"<java.version/> in POM.")
}
}

private val projectElement by lazy {soup.selectXpath("/html/body/project").single() }

/** Returns `properties > java.version` converted to `Int` or 8. */
fun javaVersion(): Int = // TODO unit test
rethrowingState(
{"POM error: java.version"},
{
projectElement.selectXpath("properties/java.version")
.firstOrNull()?.text()?.toInt() })
?: 8

fun group() = Group(required("project > groupId"))

fun version() = Version(required("project > version"))
Expand Down
16 changes: 16 additions & 0 deletions src/main/kotlin/tools/JriVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tools

/** Returns the version of runtime running this program.*/
fun jriVersion(): Int {
// https://stackoverflow.com/a/2591122/11700241
var version = System.getProperty("java.version")
if (version.startsWith("1.")) {
version = version.substring(2, 3)
} else {
val dot = version.indexOf(".")
if (dot != -1) {
version = version.substring(0, dot)
}
}
return version.toInt()
}

0 comments on commit 78f70a7

Please sign in to comment.