forked from square/dagger
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix FileNotFoundException in AGP 8.3
RELNOTES=N/A PiperOrigin-RevId: 579237165
- Loading branch information
1 parent
8801fd2
commit 6018cd2
Showing
30 changed files
with
209 additions
and
33 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
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
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
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
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
15 changes: 15 additions & 0 deletions
15
java/dagger/hilt/android/plugin/agp-wrapper-8-3/build.gradle
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,15 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' | ||
} | ||
|
||
compileKotlin { | ||
kotlinOptions { | ||
jvmTarget = 11 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':agp-wrapper') | ||
compileOnly gradleApi() | ||
compileOnly "com.android.tools.build:gradle:8.3.0-alpha11" | ||
} |
36 changes: 36 additions & 0 deletions
36
.../main/kotlin/dagger/hilt/android/plugin/util/AndroidComponentsExtensionCompatApi83Impl.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) 2023 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 AndroidComponentsExtensionCompatApi83Impl(private val project: Project) : | ||
AndroidComponentsExtensionCompat { | ||
|
||
override fun onAllVariants(block: (ComponentCompat) -> Unit) { | ||
val actual = project.extensions.getByType(AndroidComponentsExtension::class.java) | ||
actual.onVariants { variant -> | ||
block.invoke(ComponentCompatApi83Impl(variant)) | ||
|
||
(variant as? HasAndroidTest)?.androidTest?.let { block.invoke(ComponentCompatApi83Impl(it)) } | ||
|
||
variant.unitTest?.let { block.invoke(ComponentCompatApi83Impl(it)) } | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...p-wrapper-8-3/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi83Impl.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,56 @@ | ||
/* | ||
* Copyright (C) 2023 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 | ||
import java.io.File | ||
import org.gradle.api.Project | ||
|
||
internal class ComponentCompatApi83Impl(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.instrumentation.transformClassesWith( | ||
classVisitorFactoryImplClass, | ||
scope, | ||
instrumentationParamsConfig | ||
) | ||
} | ||
|
||
override fun setAsmFramesComputationMode(mode: FramesComputationMode) { | ||
component.instrumentation.setAsmFramesComputationMode(mode) | ||
} | ||
|
||
override fun getJavaCompileClassesDir(project: Project): File { | ||
// TODO(kuanyingchou): replace hardcoded path with Artifacts API: | ||
// https://developer.android.com/reference/tools/gradle-api/8.1/com/android/build/api/artifact/Artifacts | ||
val task = "compile${component.name.replaceFirstChar { it.uppercase() }}JavaWithJavac" | ||
return project.layout.buildDirectory.dir( | ||
"intermediates/javac/${component.name}/${task}/classes" | ||
).get().asFile | ||
} | ||
} |
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
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
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
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
28 changes: 28 additions & 0 deletions
28
...rc/test/data/simple-project-for-agp-test/app/src/main/java/simple/app/SimpleReceiver.java
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,28 @@ | ||
/* | ||
* Copyright (C) 2023 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 simple.app; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import dagger.hilt.android.AndroidEntryPoint; | ||
|
||
@AndroidEntryPoint | ||
class SimpleReceiver extends BroadcastReceiver { | ||
@Override | ||
public void onReceive(Context context, Intent intent) {} | ||
} |
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
Oops, something went wrong.