forked from google/dagger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract AGP version-specific code into its own modules
RELNOTES=n/a PiperOrigin-RevId: 453493907
- Loading branch information
1 parent
6380d4f
commit 9df8561
Showing
34 changed files
with
870 additions
and
250 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' | ||
} | ||
|
||
dependencies { | ||
implementation project(':agp-wrapper') | ||
implementation gradleApi() | ||
compileOnly "com.android.tools.build:gradle:4.2.0" | ||
} |
36 changes: 36 additions & 0 deletions
36
.../main/kotlin/dagger/hilt/android/plugin/util/AndroidComponentsExtensionCompatApi42Impl.kt
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,36 @@ | ||
/* | ||
* Copyright (C) 2022 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.hilt.android.plugin.util | ||
|
||
import com.android.build.api.component.Component | ||
import com.android.build.api.extension.AndroidComponentsExtension | ||
import org.gradle.api.Project | ||
|
||
@Suppress("UnstableApiUsage") | ||
class AndroidComponentsExtensionCompatApi42Impl( | ||
private val project: Project | ||
) : AndroidComponentsExtensionCompat { | ||
|
||
override fun onAllVariants(block: (ComponentCompat) -> Unit) { | ||
val actual = project.extensions.getByType(AndroidComponentsExtension::class.java) | ||
val allSelectors = actual.selector().all() | ||
val wrapFunction: (Component) -> Unit = { block.invoke(ComponentCompatApi42Impl(it)) } | ||
actual.onVariants(allSelectors, wrapFunction) | ||
actual.androidTests(allSelectors, wrapFunction) | ||
actual.unitTests(allSelectors, wrapFunction) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...p-wrapper-4-2/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi42Impl.kt
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,42 @@ | ||
/* | ||
* Copyright (C) 2022 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.hilt.android.plugin.util | ||
|
||
import com.android.build.api.component.Component | ||
import com.android.build.api.instrumentation.AsmClassVisitorFactory | ||
import com.android.build.api.instrumentation.FramesComputationMode | ||
import com.android.build.api.instrumentation.InstrumentationParameters | ||
import com.android.build.api.instrumentation.InstrumentationScope | ||
|
||
@Suppress("UnstableApiUsage") | ||
internal class ComponentCompatApi42Impl(private val component: Component) : ComponentCompat() { | ||
|
||
override val name: String | ||
get() = component.name | ||
|
||
override fun <ParamT : InstrumentationParameters> transformClassesWith( | ||
classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>, | ||
scope: InstrumentationScope, | ||
instrumentationParamsConfig: (ParamT) -> Unit | ||
) { | ||
component.transformClassesWith(classVisitorFactoryImplClass, scope, instrumentationParamsConfig) | ||
} | ||
|
||
override fun setAsmFramesComputationMode(mode: FramesComputationMode) { | ||
component.setAsmFramesComputationMode(mode) | ||
} | ||
} |
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,9 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' | ||
} | ||
|
||
dependencies { | ||
implementation project(':agp-wrapper') | ||
implementation gradleApi() | ||
compileOnly "com.android.tools.build:gradle:7.0.0" | ||
} |
43 changes: 43 additions & 0 deletions
43
.../main/kotlin/dagger/hilt/android/plugin/util/AndroidComponentsExtensionCompatApi70Impl.kt
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,43 @@ | ||
/* | ||
* Copyright (C) 2022 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.hilt.android.plugin.util | ||
|
||
import com.android.build.api.variant.AndroidComponentsExtension | ||
import com.android.build.api.variant.ApplicationVariant | ||
import com.android.build.api.variant.LibraryVariant | ||
import org.gradle.api.Project | ||
|
||
class AndroidComponentsExtensionCompatApi70Impl( | ||
private val project: Project | ||
) : AndroidComponentsExtensionCompat { | ||
|
||
@Suppress("UnstableApiUsage") | ||
override fun onAllVariants(block: (ComponentCompat) -> Unit) { | ||
val actual = project.extensions.getByType(AndroidComponentsExtension::class.java) | ||
actual.onVariants { variant -> | ||
block.invoke(ComponentCompatApi70Impl(variant)) | ||
|
||
when (variant) { | ||
is ApplicationVariant -> variant.androidTest | ||
is LibraryVariant -> variant.androidTest | ||
else -> null | ||
}?.let { block.invoke(ComponentCompatApi70Impl(it)) } | ||
|
||
variant.unitTest?.let { block.invoke(ComponentCompatApi70Impl(it)) } | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...p-wrapper-7-0/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi70Impl.kt
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,42 @@ | ||
/* | ||
* Copyright (C) 2022 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.hilt.android.plugin.util | ||
|
||
import com.android.build.api.instrumentation.AsmClassVisitorFactory | ||
import com.android.build.api.instrumentation.FramesComputationMode | ||
import com.android.build.api.instrumentation.InstrumentationParameters | ||
import com.android.build.api.instrumentation.InstrumentationScope | ||
import com.android.build.api.variant.Component | ||
|
||
internal class ComponentCompatApi70Impl(private val component: Component) : ComponentCompat() { | ||
|
||
override val name: String | ||
get() = component.name | ||
|
||
@Suppress("UnstableApiUsage") | ||
override fun <ParamT : InstrumentationParameters> transformClassesWith( | ||
classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>, | ||
scope: InstrumentationScope, | ||
instrumentationParamsConfig: (ParamT) -> Unit | ||
) { | ||
component.transformClassesWith(classVisitorFactoryImplClass, scope, instrumentationParamsConfig) | ||
} | ||
|
||
override fun setAsmFramesComputationMode(mode: FramesComputationMode) { | ||
component.setAsmFramesComputationMode(mode) | ||
} | ||
} |
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,9 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' | ||
} | ||
|
||
dependencies { | ||
implementation project(':agp-wrapper') | ||
implementation gradleApi() | ||
compileOnly "com.android.tools.build:gradle:7.1.0" | ||
} |
37 changes: 37 additions & 0 deletions
37
.../main/kotlin/dagger/hilt/android/plugin/util/AndroidComponentsExtensionCompatApi71Impl.kt
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 @@ | ||
/* | ||
* Copyright (C) 2022 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.hilt.android.plugin.util | ||
|
||
import com.android.build.api.variant.AndroidComponentsExtension | ||
import com.android.build.api.variant.HasAndroidTest | ||
import org.gradle.api.Project | ||
|
||
class AndroidComponentsExtensionCompatApi71Impl( | ||
private val project: Project | ||
) : AndroidComponentsExtensionCompat { | ||
|
||
override fun onAllVariants(block: (ComponentCompat) -> Unit) { | ||
val actual = project.extensions.getByType(AndroidComponentsExtension::class.java) | ||
actual.onVariants { variant -> | ||
block.invoke(ComponentCompatApi71Impl(variant)) | ||
|
||
(variant as? HasAndroidTest)?.androidTest?.let { block.invoke(ComponentCompatApi71Impl(it)) } | ||
|
||
variant.unitTest?.let { block.invoke(ComponentCompatApi71Impl(it)) } | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...p-wrapper-7-1/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi71Impl.kt
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,42 @@ | ||
/* | ||
* Copyright (C) 2022 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.hilt.android.plugin.util | ||
|
||
import com.android.build.api.instrumentation.AsmClassVisitorFactory | ||
import com.android.build.api.instrumentation.FramesComputationMode | ||
import com.android.build.api.instrumentation.InstrumentationParameters | ||
import com.android.build.api.instrumentation.InstrumentationScope | ||
import com.android.build.api.variant.Component | ||
|
||
internal class ComponentCompatApi71Impl(private val component: Component) : ComponentCompat() { | ||
|
||
override val name: String | ||
get() = component.name | ||
|
||
@Suppress("UnstableApiUsage") | ||
override fun <ParamT : InstrumentationParameters> transformClassesWith( | ||
classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>, | ||
scope: InstrumentationScope, | ||
instrumentationParamsConfig: (ParamT) -> Unit | ||
) { | ||
component.transformClassesWith(classVisitorFactoryImplClass, scope, instrumentationParamsConfig) | ||
} | ||
|
||
override fun setAsmFramesComputationMode(mode: FramesComputationMode) { | ||
component.setAsmFramesComputationMode(mode) | ||
} | ||
} |
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,9 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' | ||
} | ||
|
||
dependencies { | ||
implementation project(':agp-wrapper') | ||
implementation gradleApi() | ||
compileOnly "com.android.tools.build:gradle:7.2.0" | ||
} |
37 changes: 37 additions & 0 deletions
37
.../main/kotlin/dagger/hilt/android/plugin/util/AndroidComponentsExtensionCompatApi72Impl.kt
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 @@ | ||
/* | ||
* Copyright (C) 2022 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.hilt.android.plugin.util | ||
|
||
import com.android.build.api.variant.AndroidComponentsExtension | ||
import com.android.build.api.variant.HasAndroidTest | ||
import org.gradle.api.Project | ||
|
||
class AndroidComponentsExtensionCompatApi72Impl( | ||
private val project: Project | ||
) : AndroidComponentsExtensionCompat { | ||
|
||
override fun onAllVariants(block: (ComponentCompat) -> Unit) { | ||
val actual = project.extensions.getByType(AndroidComponentsExtension::class.java) | ||
actual.onVariants { variant -> | ||
block.invoke(ComponentCompatApi72Impl(variant)) | ||
|
||
(variant as? HasAndroidTest)?.androidTest?.let { block.invoke(ComponentCompatApi72Impl(it)) } | ||
|
||
variant.unitTest?.let { block.invoke(ComponentCompatApi72Impl(it)) } | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...p-wrapper-7-2/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi72Impl.kt
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,47 @@ | ||
/* | ||
* Copyright (C) 2022 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.hilt.android.plugin.util | ||
|
||
import com.android.build.api.instrumentation.AsmClassVisitorFactory | ||
import com.android.build.api.instrumentation.FramesComputationMode | ||
import com.android.build.api.instrumentation.InstrumentationParameters | ||
import com.android.build.api.instrumentation.InstrumentationScope | ||
import com.android.build.api.variant.Component | ||
|
||
internal class ComponentCompatApi72Impl(private val component: Component) : ComponentCompat() { | ||
|
||
override val name: String | ||
get() = component.name | ||
|
||
@Suppress("UnstableApiUsage") | ||
override fun <ParamT : InstrumentationParameters> transformClassesWith( | ||
classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>, | ||
scope: InstrumentationScope, | ||
instrumentationParamsConfig: (ParamT) -> Unit | ||
) { | ||
component.instrumentation.transformClassesWith( | ||
classVisitorFactoryImplClass, | ||
scope, | ||
instrumentationParamsConfig | ||
) | ||
} | ||
|
||
@Suppress("UnstableApiUsage") | ||
override fun setAsmFramesComputationMode(mode: FramesComputationMode) { | ||
component.instrumentation.setAsmFramesComputationMode(mode) | ||
} | ||
} |
Oops, something went wrong.