Skip to content

Commit 37d5789

Browse files
Check for version when resolving dependency notations (#19)
Previously we checked for the JxBrowser version right after the plugin was applied and could see the ISE in the console at this stage. Because of this, we can't configure the plugin extension with IDEA hints, as everything breaks at the stage of applying the plugin. In this PR, we do JxBrowser version checking while resolving dependency notations, not when applying the plugin.
1 parent 9ae512f commit 37d5789

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A Gradle plug-in that provides convenience methods for adding JxBrowser dependen
66

77
```kotlin
88
plugins {
9-
id("com.teamdev.jxbrowser") version "1.0.0"
9+
id("com.teamdev.jxbrowser") version "1.0.1"
1010
}
1111

1212
jxbrowser {

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2222

2323
object BuildSettings {
2424
const val GROUP = "com.teamdev.jxbrowser"
25-
const val VERSION = "1.0.0"
25+
const val VERSION = "1.0.1"
2626
const val JXBROWSER_VERSION = "7.36"
2727
val javaVersion = JavaVersion.VERSION_1_8
2828
}

src/main/kotlin/com/teamdev/jxbrowser/gradle/JxBrowserExtension.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public open class JxBrowserExtension(private val project: Project) {
6969
* Returns a dependency notation for the `jxbrowser`,
7070
* an artifact with the core API of the library.
7171
*/
72-
public val core: Provider<String> = project.providers.provider { "$GROUP:jxbrowser:$version" }
72+
public val core: Provider<String> = artifact("core")
7373

7474
/**
7575
* Returns a dependency notation for the `jxbrowser-javafx`,
@@ -154,7 +154,14 @@ public open class JxBrowserExtension(private val project: Project) {
154154
}
155155
}
156156

157-
private fun artifact(shortName: String) = project.providers.provider { "$GROUP:jxbrowser-$shortName:$version" }
157+
private fun artifact(shortName: String) = project.providers.provider {
158+
check(version.isNotBlank()) { "JxBrowser version is not specified." }
159+
if (shortName == "core") {
160+
"$GROUP:jxbrowser:$version"
161+
} else {
162+
"$GROUP:jxbrowser-$shortName:$version"
163+
}
164+
}
158165

159166
private companion object {
160167
private const val GROUP = "com.teamdev.jxbrowser"

src/main/kotlin/com/teamdev/jxbrowser/gradle/JxBrowserPlugin.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public class JxBrowserPlugin : Plugin<Project> {
5555
val extension = project.extensions.create(EXTENSION_NAME, JxBrowserExtension::class.java, project)
5656
project.addMavenRepositoryLocation(project.providers.provider { extension.repository })
5757
project.afterEvaluate {
58-
check(extension.version.isNotBlank()) { "JxBrowser version is not specified." }
5958
if (extension.includePreviewBuilds) {
6059
project.addMavenRepositoryLocation(EAP_REPOSITORY_URL)
6160
}

src/test/kotlin/com/teamdev/jxbrowser/gradle/JxBrowserPluginTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ internal class JxBrowserPluginTest {
4343
project = ProjectBuilder.builder().build()
4444
project.pluginManager.apply(pluginId)
4545
extension = project.extensions.getByType(JxBrowserExtension::class.java)
46-
extension.version = jxBrowserVersion
4746
}
4847

4948
@Test
@@ -56,6 +55,7 @@ internal class JxBrowserPluginTest {
5655
@Test
5756
fun `resolve dependencies`() {
5857
with(extension) {
58+
version = jxBrowserVersion
5959
val group = "com.teamdev.jxbrowser"
6060

6161
swt.get() shouldBe "$group:jxbrowser-swt:$jxBrowserVersion"

0 commit comments

Comments
 (0)