1 /* 2 * Copyright 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.build.sources 18 19 import androidx.build.multiplatformExtension 20 import com.google.common.truth.Truth 21 import org.gradle.testfixtures.ProjectBuilder 22 import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper 23 import org.junit.Test 24 25 class SourceJarTaskHelperTest { 26 @Test generateMetadatanull27 fun generateMetadata() { 28 val project = ProjectBuilder.builder().build() 29 project.plugins.apply(KotlinMultiplatformPluginWrapper::class.java) 30 val extension = project.multiplatformExtension!! 31 extension.jvm() 32 val commonMain = extension.sourceSets.getByName("commonMain") 33 val jvmMain = extension.sourceSets.getByName("jvmMain") 34 val extraMain = extension.sourceSets.create("extraMain") 35 extraMain.dependsOn(commonMain) 36 jvmMain.dependsOn(commonMain) 37 jvmMain.dependsOn(extraMain) 38 39 val result = createSourceSetMetadata(extension) 40 Truth.assertThat(result) 41 .isEqualTo( 42 mapOf( 43 "sourceSets" to 44 listOf( 45 mapOf( 46 "name" to "commonMain", 47 "dependencies" to emptyList<String>(), 48 "analysisPlatform" to "common" 49 ), 50 mapOf( 51 "name" to "extraMain", 52 "dependencies" to listOf("commonMain"), 53 "analysisPlatform" to "jvm" 54 ), 55 mapOf( 56 "name" to "jvmMain", 57 "dependencies" to listOf("commonMain", "extraMain"), 58 "analysisPlatform" to "jvm" 59 ) 60 ) 61 ) 62 ) 63 } 64 } 65