Skip to content

Commit

Permalink
update project
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyDev05 committed Jan 21, 2025
1 parent 5b9bc71 commit 1e04d48
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 40 deletions.
6 changes: 1 addition & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
import java.net.URI

// Workaround for (https://youtrack.jetbrains.com/issue/KTIJ-19369)
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
java
kotlin("jvm") version "1.9.0"
kotlin("jvm") version "2.1.0"
id("com.github.hierynomus.license-base") version "0.16.1"
}

Expand All @@ -33,8 +31,6 @@ allprojects {
}

dependencies {
// implementation(kotlin("bom:${rootProject.libs.versions.kotlin.get()}")) // Keep kotlin versions in sync.

testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}
Expand Down
24 changes: 12 additions & 12 deletions gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

// Workaround for (https://youtrack.jetbrains.com/issue/KTIJ-19369)
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
`maven-publish`
`java-gradle-plugin`
id("com.gradleup.shadow") version "8.3.3"
kotlin("jvm") version "1.9.0"
id("com.gradleup.shadow") version "8.3.5"
kotlin("jvm")
}

repositories {
Expand All @@ -19,16 +19,16 @@ configurations["testImplementation"].extendsFrom(shadowImplementation)

dependencies {

shadowImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
shadowImplementation("org.jetbrains.kotlin:kotlin-stdlib:2.1.0")
shadowImplementation(project(":slimjar"))
shadowImplementation("com.google.code.gson:gson:2.10")
shadowImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.9.0")
shadowImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1")

compileOnly(gradleApi())
compileOnly(gradleKotlinDsl())
compileOnly("com.gradleup.shadow:shadow-gradle-plugin:8.3.3")
compileOnly("com.gradleup.shadow:shadow-gradle-plugin:8.3.5")

testImplementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.3")
testImplementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.5")
testImplementation("org.assertj:assertj-core:3.23.1")
testImplementation(gradleApi())
testImplementation(gradleKotlinDsl())
Expand Down Expand Up @@ -96,10 +96,10 @@ tasks {
}

withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
languageVersion = "1.7"
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
languageVersion.set(KotlinVersion.KOTLIN_1_7)
freeCompilerArgs.addAll("-opt-in=kotlin.RequiresOptIn")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public class SlimJarPlugin : Plugin<Project> {
)
}

val slimJar = tasks.create(SLIM_JAR_TASK_NAME, SlimJar::class.java, slimConfig, slimJarExtension)
val slimJar = tasks.register(SLIM_JAR_TASK_NAME, SlimJar::class.java, slimConfig, slimJarExtension)
project.dependencies.extra.set(
"slimjar",
asGroovyClosure("+") { version -> slimJarLib(version) }
)
// Hooks into shadow to inject relocations
tasks.withType<ShadowJar>() {
tasks.withType<ShadowJar> {
doFirst { _ ->
slimExtension.relocations.forEach { rule ->
relocate(rule.originalPackagePattern, rule.relocatedPackagePattern) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.buffer
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.emitAll
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.runBlocking
Expand All @@ -74,7 +76,7 @@ import org.gradle.kotlin.dsl.* // ktlint-disable no-wildcard-imports
import java.io.File
import java.io.FileReader
import java.io.FileWriter
import java.net.URL
import java.net.URI
import javax.inject.Inject

@CacheableTask
Expand Down Expand Up @@ -178,7 +180,7 @@ public abstract class SlimJar @Inject constructor(
// TODO: Cleanup this mess
runBlocking(IO) {
val globalRepositoryEnquirer = extension.globalRepositories.map { repos ->
repos.map { repoString -> enquirerFactory.create(Repository(URL(repoString))) }
repos.map { repoString -> enquirerFactory.create(Repository(URI.create(repoString).toURL())) }
}

dependencies.asFlow()
Expand Down Expand Up @@ -294,7 +296,12 @@ public abstract class SlimJar @Inject constructor(
): Flow<R> = this
.map { scope.async { transform(it) } }
.buffer(concurrencyLevel)
.map { it.await() }
.map { it::await.asFlow() }
.flattenConcat()

private fun <T> Flow<Flow<T>>.flattenConcat(): Flow<T> = flow {
collect { value -> emitAll(value) }
}

protected open fun withShadowTask(
action: ShadowJar.() -> Unit
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group=de.crazydev22.slimjar
version=1.6.1
kotlinVersion=1.9.0
build=121
version=1.7.0
kotlinVersion=2.1.0
build=0
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 12 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rootProject.name = "slimjar"

include("slimjar", "slimjar-external", "gradle-plugin", "loader-agent")
include("slimjar", "gradle-plugin", "loader-agent")

pluginManagement {
repositories {
Expand Down
10 changes: 4 additions & 6 deletions slimjar/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Workaround for (https://youtrack.jetbrains.com/issue/KTIJ-19369)
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.gradleup.shadow") version "8.3.5"
`maven-publish`
}

dependencies {
testImplementation("me.lucko:jar-relocator:1.7")
testImplementation("com.google.code.gson:gson:2.10")
testImplementation("org.mockito:mockito-core:4.10.0")
testImplementation("org.mockito:mockito-inline:4.10.0")
testImplementation("com.google.code.gson:gson:2.11.0")
testImplementation("org.mockito:mockito-core:5.15.2")
testImplementation("org.mockito:mockito-inline:5.15.2")
testImplementation("cglib:cglib:3.3.0")
}

Expand Down

0 comments on commit 1e04d48

Please sign in to comment.