-
Notifications
You must be signed in to change notification settings - Fork 42
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
263 changed files
with
5,238 additions
and
752 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,37 @@ | ||
import java.util.concurrent.atomic.AtomicBoolean | ||
import org.gradle.api.Project | ||
|
||
enum class SupportedIJVersion { | ||
IJ_232, | ||
IJ_233 | ||
} | ||
|
||
private var warned = AtomicBoolean(false) | ||
|
||
fun Project.supportedIJVersion(): SupportedIJVersion { | ||
val prop = kotlin.runCatching { | ||
localProperty("supported.ij.version") | ||
?: rootProject.property("supported.ij.version")?.toString() | ||
}.getOrNull() | ||
|
||
if (prop == null) { | ||
if (!warned.getAndSet(true)) { | ||
logger.warn( | ||
""" | ||
No 'supported.ij.version' property provided. Falling back to IJ 233. | ||
It is recommended to provide it using local.properties file or -Psupported.ij.version to avoid unexpected behavior. | ||
""".trimIndent() | ||
) | ||
} | ||
return SupportedIJVersion.IJ_233 | ||
} | ||
|
||
return when (prop) { | ||
"232" -> SupportedIJVersion.IJ_232 | ||
"233" -> SupportedIJVersion.IJ_233 | ||
else -> error( | ||
"Invalid 'supported.ij.version' with value '$prop' is provided. " + | ||
"It should be in set of these values: ('232', '233')" | ||
) | ||
} | ||
} |
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,12 @@ | ||
import org.gradle.api.Project | ||
import java.util.Properties | ||
|
||
internal fun Project.localProperty(propertyName: String): String? { | ||
val localPropertiesFile = rootProject.file("local.properties") | ||
if (!localPropertiesFile.exists()) { | ||
return null | ||
} | ||
val properties = Properties() | ||
localPropertiesFile.inputStream().use { properties.load(it) } | ||
return properties.getProperty(propertyName) | ||
} |
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,35 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.MavenPom | ||
import org.gradle.kotlin.dsl.assign | ||
import org.gradle.kotlin.dsl.maven | ||
|
||
internal fun PublishingExtension.configureJewelRepositories() { | ||
repositories { | ||
maven("https://packages.jetbrains.team/maven/p/kpm/public") { | ||
name = "Space" | ||
credentials { | ||
username = System.getenv("MAVEN_SPACE_USERNAME") | ||
password = System.getenv("MAVEN_SPACE_PASSWORD") | ||
} | ||
} | ||
} | ||
} | ||
|
||
internal fun MavenPom.configureJewelPom() { | ||
name = "Jewel" | ||
description = "A theme for Compose for Desktop that implements the IntelliJ Platform look and feel." | ||
url = "https://github.com/JetBrains/jewel" | ||
licenses { | ||
license { | ||
name = "Apache License 2.0" | ||
url = "http://www.apache.org/licenses/LICENSE-2.0.txt" | ||
} | ||
} | ||
scm { | ||
connection = "scm:git:https://github.com/JetBrains/jewel.git" | ||
developerConnection = "scm:git:https://github.com/JetBrains/jewel.git" | ||
url = "https://github.com/JetBrains/jewel" | ||
} | ||
} |
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,63 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
import SupportedIJVersion.IJ_232 | ||
import SupportedIJVersion.IJ_233 | ||
|
||
plugins { | ||
kotlin("jvm") | ||
`maven-publish` | ||
id("org.jetbrains.dokka") | ||
} | ||
|
||
val sourcesJar by tasks.registering(Jar::class) { | ||
from(kotlin.sourceSets.main.map { it.kotlin }) | ||
archiveClassifier = "sources" | ||
destinationDirectory = layout.buildDirectory.dir("artifacts") | ||
} | ||
|
||
val javadocJar by tasks.registering(Jar::class) { | ||
from(tasks.dokkaHtml) | ||
archiveClassifier = "javadoc" | ||
destinationDirectory = layout.buildDirectory.dir("artifacts") | ||
} | ||
|
||
publishing { | ||
configureJewelRepositories() | ||
|
||
publications { | ||
register<MavenPublication>("IdeMain") { | ||
from(components["kotlin"]) | ||
artifact(javadocJar) | ||
artifact(sourcesJar) | ||
val ijVersionRaw = when (supportedIJVersion()) { | ||
IJ_232 -> "232" | ||
IJ_233 -> "233" | ||
} | ||
version = project.version.toString().withVersionSuffix("ij-$ijVersionRaw") | ||
artifactId = "jewel-${project.name}" | ||
pom { | ||
configureJewelPom() | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Adds suffix to the version taking SNAPSHOT suffix into account | ||
* | ||
* For example, if [this] is "0.0.1-SNAPSHOT" and [suffix] is "ij-233" | ||
* then result will be "0.0.1-ij-233-SNAPSHOT" | ||
*/ | ||
fun String.withVersionSuffix(suffix: String): String { | ||
val splitString = this.split('-') | ||
val snapshotRaw = "SNAPSHOT" | ||
val withSnapshot = splitString.contains(snapshotRaw) | ||
|
||
if (!withSnapshot) { | ||
return "$this-$suffix" | ||
} | ||
|
||
val withoutSnapshot = splitString.filter { it != snapshotRaw }.joinToString("-") | ||
|
||
return "$withoutSnapshot-$suffix-$snapshotRaw" | ||
} |
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
Oops, something went wrong.