Skip to content

Commit

Permalink
💚 support offline build
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavst committed Nov 9, 2021
1 parent d4353cd commit c22d582
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 22 deletions.
94 changes: 79 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.5.0'
buildscript {
repositories {
mavenCentral()
}
dependencies {
if (project.getGradle().startParameter.isOffline())
classpath fileTree(include: ['*.jar'], dir: project.findProperty("OFFLINE_BUILD_PATH"))
else
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
}
}

apply plugin: 'kotlin'


group 'org.yoavst.jeb'
version '0.4.0'

repositories {
maven { url './offline' }
jcenter()
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

Expand All @@ -38,12 +45,69 @@ jar {
}
}

repositories {
mavenCentral()
}

dependencies {
compileOnly fileTree(dir: 'libs/runtime', include: ['*.jar'])
compileOnly 'org.python:jython:2.7.0'

compile platform('org.jetbrains.kotlin:kotlin-bom')
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
compile 'org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.3.0'
compile 'org.apache.commons:commons-text:1.9'
}
if (project.getGradle().startParameter.isOffline()) {
compile fileTree(dir: project.findProperty('OFFLINE_COMPILE_PATH'), include: ['*.jar'])
compileOnly fileTree(dir: project.findProperty('OFFLINE_COMPILE_ONLY_PATH'), include: ['*.jar'])
} else {
compileOnly fileTree(dir: 'libs/runtime', include: ['*.jar'])
compileOnly 'org.python:jython:2.7.0'

compile platform('org.jetbrains.kotlin:kotlin-bom')
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
compile 'org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.3.0'
compile 'org.apache.commons:commons-text:1.9'
}
}

//region Offline
task resolveDependencies {
configurations.compile.resolve()
configurations.compileOnly.resolve()
}
task copyCompileOnly(type: Copy) {
configurations.compileOnly
.filter { it.absolutePath.endsWith("jar") }
.forEach {
from it.absolutePath
into project.findProperty('OFFLINE_COMPILE_ONLY_PATH')
}
}

task copyCompile(type: Copy) {
configurations.compile
.filter { it.absolutePath.endsWith("jar") }
.forEach {
from it.absolutePath
into project.findProperty('OFFLINE_COMPILE_PATH')
}
}

task copyPluginDependencies {
doLast {
def dependencies = []
buildscript.configurations.classpath.each { dependency ->
dependencies.add(dependency)
}
dependencies.unique().each { dependency ->
copy {
from dependency.absolutePath
into project.findProperty("OFFLINE_BUILD_PATH")
}
}
}
}


task copyDependencies(type: Copy) {
def tasks = [resolveDependencies, copyCompile, copyCompileOnly, copyPluginDependencies]
for (int i = 0; i < tasks.size() - 1; i++) {
tasks[i + 1].mustRunAfter(tasks[i])
}
dependsOn(tasks)
}
//endregion
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OFFLINE_BASE_PATH=offline
OFFLINE_BUILD_PATH=offline/build
OFFLINE_COMPILE_PATH=offline/compile
OFFLINE_COMPILE_ONLY_PATH=offline/compileOnly
7 changes: 0 additions & 7 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
pluginManagement {
repositories {
maven { url './offline' }
gradlePluginPortal()
}
}

rootProject.name = 'JebOps'

0 comments on commit c22d582

Please sign in to comment.