@@ -2848,6 +2848,77 @@ void main() {
2848
2848
expect (buildContent.contains ('targetSdkVersion flutter.targetSdkVersion' ), true );
2849
2849
});
2850
2850
2851
+ testUsingContext ('Android Java plugin contains namespace' , () async {
2852
+ Cache .flutterRoot = '../..' ;
2853
+
2854
+ final CreateCommand command = CreateCommand ();
2855
+ final CommandRunner <void > runner = createTestCommandRunner (command);
2856
+
2857
+ await runner.run (< String > ['create' , '--no-pub' ,
2858
+ '-t' , 'plugin' ,
2859
+ '--org' , 'com.bar.foo' ,
2860
+ '-a' , 'java' ,
2861
+ '--platforms=android' ,
2862
+ projectDir.path]);
2863
+
2864
+ final File buildGradleFile = globals.fs.file ('${projectDir .path }/android/build.gradle' );
2865
+
2866
+ expect (buildGradleFile.existsSync (), true );
2867
+
2868
+ final String buildGradleContent = await buildGradleFile.readAsString ();
2869
+
2870
+ expect (buildGradleContent.contains ("namespace 'com.bar.foo.flutter_project'" ), true );
2871
+ // The namespace should be conditionalized for AGP <4.2.
2872
+ expect (buildGradleContent.contains ('if (project.android.hasProperty("namespace")) {' ), true );
2873
+ });
2874
+
2875
+ testUsingContext ('Android FFI plugin contains namespace' , () async {
2876
+ Cache .flutterRoot = '../..' ;
2877
+
2878
+ final CreateCommand command = CreateCommand ();
2879
+ final CommandRunner <void > runner = createTestCommandRunner (command);
2880
+
2881
+ await runner.run (< String > ['create' , '--no-pub' ,
2882
+ '-t' , 'plugin_ffi' ,
2883
+ '--org' , 'com.bar.foo' ,
2884
+ '--platforms=android' ,
2885
+ projectDir.path]);
2886
+
2887
+ final File buildGradleFile = globals.fs.file ('${projectDir .path }/android/build.gradle' );
2888
+
2889
+ expect (buildGradleFile.existsSync (), true );
2890
+
2891
+ final String buildGradleContent = await buildGradleFile.readAsString ();
2892
+
2893
+ expect (buildGradleContent.contains ("namespace 'com.bar.foo.flutter_project'" ), true );
2894
+ // The namespace should be conditionalized for AGP <4.2.
2895
+ expect (buildGradleContent.contains ('if (project.android.hasProperty("namespace")) {' ), true );
2896
+ });
2897
+
2898
+ testUsingContext ('Android Kotlin plugin contains namespace' , () async {
2899
+ Cache .flutterRoot = '../..' ;
2900
+
2901
+ final CreateCommand command = CreateCommand ();
2902
+ final CommandRunner <void > runner = createTestCommandRunner (command);
2903
+
2904
+ await runner.run (< String > ['create' , '--no-pub' ,
2905
+ '-t' , 'plugin' ,
2906
+ '--org' , 'com.bar.foo' ,
2907
+ '-a' , 'kotlin' ,
2908
+ '--platforms=android' ,
2909
+ projectDir.path]);
2910
+
2911
+ final File buildGradleFile = globals.fs.file ('${projectDir .path }/android/build.gradle' );
2912
+
2913
+ expect (buildGradleFile.existsSync (), true );
2914
+
2915
+ final String buildGradleContent = await buildGradleFile.readAsString ();
2916
+
2917
+ expect (buildGradleContent.contains ("namespace 'com.bar.foo.flutter_project'" ), true );
2918
+ // The namespace should be conditionalized for AGP <4.2.
2919
+ expect (buildGradleContent.contains ('if (project.android.hasProperty("namespace")) {' ), true );
2920
+ });
2921
+
2851
2922
testUsingContext ('Linux plugins handle partially camel-case project names correctly' , () async {
2852
2923
Cache .flutterRoot = '../..' ;
2853
2924
0 commit comments