mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
IDEA-254380 Get rid of offline-repo in IDEA/android tests
Remove dependency on `org.jetbrains.intellij.deps.android.tools.base:android-sdk-offline-repo` in IDEA. For layoutlib use the same artifact as IDEA uses in runtime (`org.jetbrains.intellij.deps.android.tools.base:layoutlib-resources`) GitOrigin-RevId: 2c2fd4aa2929778834774c96ca758cdef4110568
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4f85cad48f
commit
80d0b3eb2b
@@ -27,7 +27,7 @@ repositories {
|
||||
}
|
||||
|
||||
configurations {
|
||||
androidOfflineRepo
|
||||
androidLayoutlib
|
||||
androidSdk
|
||||
kotlinDeps
|
||||
}
|
||||
@@ -49,11 +49,11 @@ ext.kotlin_version = kotlinPluginBuild.substring(
|
||||
4, // number of chars in "203-" string (or "202-" string or any other platform identifier with dash string)
|
||||
kotlinVersionLen
|
||||
)
|
||||
ext.android_m2_version = "27.1.0.0" // 27.1.1.0 is not published because there are no changes comparing to current version
|
||||
ext.android_sdk_version = "${osFamily}.4.0.0.0"
|
||||
ext.android_layoutlib_version = "27.1.1.1"
|
||||
|
||||
dependencies {
|
||||
androidOfflineRepo "org.jetbrains.intellij.deps.android.tools.base:android-sdk-offline-repo:${android_m2_version}@zip"
|
||||
androidLayoutlib "org.jetbrains.intellij.deps.android.tools.base:layoutlib-resources:${android_layoutlib_version}"
|
||||
androidSdk "org.jetbrains.intellij.deps.android:android-sdk:${android_sdk_version}:@tar.gz"
|
||||
kotlinDeps "org.jetbrains.kotlin:kotlin-android-extensions:${kotlin_version}"
|
||||
kotlinDeps "org.jetbrains.kotlin:kotlin-android-extensions-runtime:${kotlin_version}"
|
||||
@@ -78,20 +78,20 @@ dependencies {
|
||||
kotlinDeps "org.jetbrains.kotlin:kotlin-test-common:${kotlin_version}"
|
||||
}
|
||||
|
||||
task syncAndroidSdk(dependsOn: [configurations.androidSdk, configurations.androidOfflineRepo], type: SyncAndroidSdkTask) {
|
||||
task syncAndroidSdk(dependsOn: [configurations.androidSdk, configurations.androidLayoutlib], type: SyncAndroidSdkTask) {
|
||||
CopyUnitOfWork.project = project
|
||||
work = [
|
||||
new CopyData().with {
|
||||
it.from = configurations.androidOfflineRepo.name
|
||||
it.into = "${project.buildDir}/android-sdk"
|
||||
it.versionFile = android_m2_version
|
||||
it.from = configurations.androidLayoutlib.name
|
||||
it.into = "${project.buildDir}/android-sdk/layoutlib"
|
||||
it.versionFile = android_layoutlib_version
|
||||
it
|
||||
}, new CopyData().with {
|
||||
it.from = configurations.androidSdk.name
|
||||
it.into = "$buildDir/android-sdk/prebuilts/studio/sdk"
|
||||
it.versionFile = android_sdk_version
|
||||
it
|
||||
},
|
||||
it.from = configurations.androidSdk.name
|
||||
it.into = "$buildDir/android-sdk/prebuilts/studio/sdk"
|
||||
it.versionFile = android_sdk_version
|
||||
it
|
||||
},
|
||||
]
|
||||
onlyIf {
|
||||
work.any {
|
||||
@@ -114,19 +114,12 @@ task syncKotlinPluginForAndroid(dependsOn: [setupKotlinPlugin, syncAndroidSdk],
|
||||
into "$buildDir/android-sdk/prebuilts/tools/common/kotlin-plugin"
|
||||
}
|
||||
|
||||
task updateKotlinLibs(dependsOn: [configurations.kotlinDeps, syncAndroidSdk], type: OfflineMavenRepository) {
|
||||
def verFile = "${project.buildDir}/android-sdk/prebuilts/tools/common/m2/repository/org/jetbrains/kotlin/${kotlin_version}"
|
||||
configurationName = "kotlinDeps"
|
||||
repoDir = file("$buildDir/android-sdk/prebuilts/tools/common/m2/repository")
|
||||
doLast {
|
||||
file(verFile).write(kotlin_version)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is entry point: invoke this task to setup android sdk and all the artifacts required to run android-plugin unit tests
|
||||
*/
|
||||
task setupAndroidSdk(dependsOn: [syncAndroidSdk, syncKotlinPluginForAndroid, updateKotlinLibs])
|
||||
task setupAndroidSdk(dependsOn: [syncAndroidSdk, syncKotlinPluginForAndroid]) {
|
||||
|
||||
}
|
||||
|
||||
class CopyData implements Serializable {
|
||||
String from
|
||||
@@ -210,41 +203,6 @@ class CopyUnitOfWork implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Copy task implementation is not as lazy as we need: dependencies from androidOfflineRepo and androidSdk configurations will be
|
||||
* downloaded even if no executable task will use them later.
|
||||
* See discussions here: https://discuss.gradle.org/t/lazy-configuration-resolution-with-artifact-repack/12747/5
|
||||
* and here: https://discuss.gradle.org/t/lazy-dependency-resolution-completely-conditional-configuration-dependency/5032
|
||||
*/
|
||||
class VersionedLazyCopyTask extends DefaultTask {
|
||||
Closure from
|
||||
File into
|
||||
File versionFile
|
||||
void setInto(String into) {
|
||||
this.into = new File(into)
|
||||
}
|
||||
|
||||
void setVersionFile(String versionStr) {
|
||||
this.versionFile = new File(into, "${versionStr}.version")
|
||||
onlyIf {
|
||||
!versionFile.exists()
|
||||
}
|
||||
|
||||
doFirst {
|
||||
into.deleteDir()
|
||||
}
|
||||
|
||||
doLast {
|
||||
println ">> copying files into ${into}. Please be patient."
|
||||
getProject().copy {
|
||||
from this.from
|
||||
into this.into
|
||||
}
|
||||
versionFile.createNewFile()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SyncAndroidSdkTask extends DefaultTask {
|
||||
Collection<CopyData> work
|
||||
WorkerExecutor workerExecutor
|
||||
@@ -264,49 +222,3 @@ class SyncAndroidSdkTask extends DefaultTask {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OfflineMavenRepository extends DefaultTask {
|
||||
@Input
|
||||
String configurationName = 'compile'
|
||||
|
||||
File repoDir
|
||||
|
||||
@TaskAction
|
||||
void build() {
|
||||
Configuration configuration = project.configurations.getByName(configurationName)
|
||||
copyJars(configuration)
|
||||
copyPoms(configuration)
|
||||
}
|
||||
|
||||
private void copyJars(Configuration configuration) {
|
||||
configuration.resolvedConfiguration.resolvedArtifacts.each { artifact ->
|
||||
def moduleVersionId = artifact.moduleVersion.id
|
||||
File moduleDir = new File(repoDir, "${moduleVersionId.group.replace('.', '/')}/${moduleVersionId.name}/${moduleVersionId.version}")
|
||||
GFileUtils.mkdirs(moduleDir)
|
||||
|
||||
File target = new File(moduleDir, artifact.file.name)
|
||||
println "Copy: $artifact.file -> $target"
|
||||
GFileUtils.copyFile(artifact.file, target)
|
||||
}
|
||||
}
|
||||
|
||||
private void copyPoms(Configuration configuration) {
|
||||
def componentIds = configuration.incoming.resolutionResult.allDependencies.collect { it.selected.id }
|
||||
|
||||
def result = project.dependencies.createArtifactResolutionQuery()
|
||||
.forComponents(componentIds)
|
||||
.withArtifacts(MavenModule, MavenPomArtifact)
|
||||
.execute()
|
||||
|
||||
for (component in result.resolvedComponents) {
|
||||
def componentId = component.id
|
||||
|
||||
if (componentId instanceof ModuleComponentIdentifier) {
|
||||
File moduleDir = new File(repoDir, "${componentId.group.replace('.', '/')}/${componentId.module}/${componentId.version}")
|
||||
GFileUtils.mkdirs(moduleDir)
|
||||
File pomFile = component.getArtifacts(MavenPomArtifact)[0].file
|
||||
GFileUtils.copyFile(pomFile, new File(moduleDir, pomFile.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user