From 8fa51030257872978587adfac99ba089efd84115 Mon Sep 17 00:00:00 2001 From: Tanish-Ranjan Date: Tue, 16 Jul 2024 20:34:38 +0530 Subject: [PATCH 01/15] Added an android java test project --- testProjects/android-test/.gitignore | 15 ++ testProjects/android-test/app/.gitignore | 1 + testProjects/android-test/app/build.gradle | 39 ++++ .../android-test/app/proguard-rules.pro | 21 ++ .../androidtest/ExampleInstrumentedTest.java | 26 +++ .../app/src/main/AndroidManifest.xml | 26 +++ .../com/example/androidtest/MainActivity.java | 24 +++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++ .../res/drawable/ic_launcher_foreground.xml | 30 +++ .../app/src/main/res/layout/activity_main.xml | 10 + .../main/res/mipmap-anydpi/ic_launcher.xml | 6 + .../res/mipmap-anydpi/ic_launcher_round.xml | 6 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes .../app/src/main/res/values-night/themes.xml | 16 ++ .../app/src/main/res/values/colors.xml | 10 + .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/themes.xml | 16 ++ .../app/src/main/res/xml/backup_rules.xml | 13 ++ .../main/res/xml/data_extraction_rules.xml | 19 ++ .../example/androidtest/ExampleUnitTest.java | 17 ++ testProjects/android-test/build.gradle | 4 + testProjects/android-test/gradle.properties | 21 ++ .../android-test/gradle/libs.versions.toml | 22 +++ .../gradle/wrapper/gradle-wrapper.properties | 6 + testProjects/android-test/gradlew | 185 ++++++++++++++++++ testProjects/android-test/gradlew.bat | 89 +++++++++ testProjects/android-test/settings.gradle | 23 +++ 36 files changed, 818 insertions(+) create mode 100644 testProjects/android-test/.gitignore create mode 100644 testProjects/android-test/app/.gitignore create mode 100644 testProjects/android-test/app/build.gradle create mode 100644 testProjects/android-test/app/proguard-rules.pro create mode 100644 testProjects/android-test/app/src/androidTest/java/com/example/androidtest/ExampleInstrumentedTest.java create mode 100644 testProjects/android-test/app/src/main/AndroidManifest.xml create mode 100644 testProjects/android-test/app/src/main/java/com/example/androidtest/MainActivity.java create mode 100644 testProjects/android-test/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 testProjects/android-test/app/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 testProjects/android-test/app/src/main/res/layout/activity_main.xml create mode 100644 testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher.xml create mode 100644 testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml create mode 100644 testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 testProjects/android-test/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 testProjects/android-test/app/src/main/res/values-night/themes.xml create mode 100644 testProjects/android-test/app/src/main/res/values/colors.xml create mode 100644 testProjects/android-test/app/src/main/res/values/strings.xml create mode 100644 testProjects/android-test/app/src/main/res/values/themes.xml create mode 100644 testProjects/android-test/app/src/main/res/xml/backup_rules.xml create mode 100644 testProjects/android-test/app/src/main/res/xml/data_extraction_rules.xml create mode 100644 testProjects/android-test/app/src/test/java/com/example/androidtest/ExampleUnitTest.java create mode 100644 testProjects/android-test/build.gradle create mode 100644 testProjects/android-test/gradle.properties create mode 100644 testProjects/android-test/gradle/libs.versions.toml create mode 100644 testProjects/android-test/gradle/wrapper/gradle-wrapper.properties create mode 100644 testProjects/android-test/gradlew create mode 100644 testProjects/android-test/gradlew.bat create mode 100644 testProjects/android-test/settings.gradle diff --git a/testProjects/android-test/.gitignore b/testProjects/android-test/.gitignore new file mode 100644 index 00000000..aa724b77 --- /dev/null +++ b/testProjects/android-test/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/testProjects/android-test/app/.gitignore b/testProjects/android-test/app/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/testProjects/android-test/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/testProjects/android-test/app/build.gradle b/testProjects/android-test/app/build.gradle new file mode 100644 index 00000000..2d12cba1 --- /dev/null +++ b/testProjects/android-test/app/build.gradle @@ -0,0 +1,39 @@ +plugins { + alias(libs.plugins.android.application) +} + +android { + namespace 'com.example.androidtest' + compileSdk 34 + + defaultConfig { + applicationId "com.example.androidtest" + minSdk 26 + targetSdk 34 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation libs.appcompat + implementation libs.material + implementation libs.activity + implementation libs.constraintlayout + testImplementation libs.junit + androidTestImplementation libs.ext.junit + androidTestImplementation libs.espresso.core +} \ No newline at end of file diff --git a/testProjects/android-test/app/proguard-rules.pro b/testProjects/android-test/app/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/testProjects/android-test/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/testProjects/android-test/app/src/androidTest/java/com/example/androidtest/ExampleInstrumentedTest.java b/testProjects/android-test/app/src/androidTest/java/com/example/androidtest/ExampleInstrumentedTest.java new file mode 100644 index 00000000..9451b02e --- /dev/null +++ b/testProjects/android-test/app/src/androidTest/java/com/example/androidtest/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.androidtest; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.androidtest", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/AndroidManifest.xml b/testProjects/android-test/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a7f9f2ca --- /dev/null +++ b/testProjects/android-test/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/java/com/example/androidtest/MainActivity.java b/testProjects/android-test/app/src/main/java/com/example/androidtest/MainActivity.java new file mode 100644 index 00000000..1315acc0 --- /dev/null +++ b/testProjects/android-test/app/src/main/java/com/example/androidtest/MainActivity.java @@ -0,0 +1,24 @@ +package com.example.androidtest; + +import android.os.Bundle; + +import androidx.activity.EdgeToEdge; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EdgeToEdge.enable(this); + setContentView(R.layout.activity_main); + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { + Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); + return insets; + }); + } +} \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/drawable/ic_launcher_background.xml b/testProjects/android-test/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/testProjects/android-test/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testProjects/android-test/app/src/main/res/drawable/ic_launcher_foreground.xml b/testProjects/android-test/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/testProjects/android-test/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/layout/activity_main.xml b/testProjects/android-test/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..9affce0f --- /dev/null +++ b/testProjects/android-test/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher.xml new file mode 100644 index 00000000..6f3b755b --- /dev/null +++ b/testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 00000000..6f3b755b --- /dev/null +++ b/testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000000000000000000000000000000000000..c209e78ecd372343283f4157dcfd918ec5165bb3 GIT binary patch literal 1404 zcmV-?1%vuhNk&F=1pok7MM6+kP&il$0000G0000-002h-06|PpNX!5L00Dqw+t%{r zzW2vH!KF=w&cMnnN@{whkTw+#mAh0SV?YL=)3MimFYCWp#fpdtz~8$hD5VPuQgtcN zXl<@<#Cme5f5yr2h%@8TWh?)bSK`O z^Z@d={gn7J{iyxL_y_%J|L>ep{dUxUP8a{byupH&!UNR*OutO~0{*T4q5R6@ApLF! z5{w?Z150gC7#>(VHFJZ-^6O@PYp{t!jH(_Z*nzTK4 zkc{fLE4Q3|mA2`CWQ3{8;gxGizgM!zccbdQoOLZc8hThi-IhN90RFT|zlxh3Ty&VG z?Fe{#9RrRnxzsu|Lg2ddugg7k%>0JeD+{XZ7>Z~{=|M+sh1MF7~ zz>To~`~LVQe1nNoR-gEzkpe{Ak^7{{ZBk2i_<+`Bq<^GB!RYG+z)h;Y3+<{zlMUYd zrd*W4w&jZ0%kBuDZ1EW&KLpyR7r2=}fF2%0VwHM4pUs}ZI2egi#DRMYZPek*^H9YK zay4Iy3WXFG(F14xYsoDA|KXgGc5%2DhmQ1gFCkrgHBm!lXG8I5h*uf{rn48Z!_@ z4Bk6TJAB2CKYqPjiX&mWoW>OPFGd$wqroa($ne7EUK;#3VYkXaew%Kh^3OrMhtjYN?XEoY`tRPQsAkH-DSL^QqyN0>^ zmC>{#F14jz4GeW{pJoRpLFa_*GI{?T93^rX7SPQgT@LbLqpNA}<@2wH;q493)G=1Y z#-sCiRNX~qf3KgiFzB3I>4Z%AfS(3$`-aMIBU+6?gbgDb!)L~A)je+;fR0jWLL-Fu z4)P{c7{B4Hp91&%??2$v9iRSFnuckHUm}or9seH6 z>%NbT+5*@L5(I9j@06@(!{ZI?U0=pKn8uwIg&L{JV14+8s2hnvbRrU|hZCd}IJu7*;;ECgO%8_*W Kmw_-CKmY()leWbG literal 0 HcmV?d00001 diff --git a/testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000000000000000000000000000000000000..b2dfe3d1ba5cf3ee31b3ecc1ced89044a1f3b7a9 GIT binary patch literal 2898 zcmV-Y3$650Nk&FW3jhFDMM6+kP&il$0000G0000-002h-06|PpNWB9900E$G+qN-D z+81ABX7q?;bwx%xBg?kcwr$(C-Tex-ZCkHUw(Y9#+`E5-zuONG5fgw~E2WDng@Bc@ z24xy+R1n%~6xI#u9vJ8zREI)sb<&Il(016}Z~V1n^PU3-_H17A*Bf^o)&{_uBv}Py zulRfeE8g(g6HFhk_?o_;0@tz?1I+l+Y#Q*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!u$OoxLlE;WdrNlN)1 z7**de7-hZ!(%_ZllHBLg`Ir#|t>2$*xVOZ-ADZKTN?{(NUeLU9GbuG-+Axf*AZ-P1 z0ZZ*fx+ck4{XtFsbcc%GRStht@q!m*ImssGwuK+P@%gEK!f5dHymg<9nSCXsB6 zQ*{<`%^bxB($Z@5286^-A(tR;r+p7B%^%$N5h%lb*Vlz-?DL9x;!j<5>~kmXP$E}m zQV|7uv4SwFs0jUervsxVUm>&9Y3DBIzc1XW|CUZrUdb<&{@D5yuLe%Xniw^x&{A2s z0q1+owDSfc3Gs?ht;3jw49c#mmrViUfX-yvc_B*wY|Lo7; zGh!t2R#BHx{1wFXReX*~`NS-LpSX z#TV*miO^~B9PF%O0huw!1Zv>^d0G3$^8dsC6VI!$oKDKiXdJt{mGkyA`+Gwd4D-^1qtNTUK)`N*=NTG-6}=5k6suNfdLt*dt8D| z%H#$k)z#ZRcf|zDWB|pn<3+7Nz>?WW9WdkO5(a^m+D4WRJ9{wc>Y}IN)2Kbgn;_O? zGqdr&9~|$Y0tP=N(k7^Eu;iO*w+f%W`20BNo)=Xa@M_)+o$4LXJyiw{F?a633SC{B zl~9FH%?^Rm*LVz`lkULs)%idDX^O)SxQol(3jDRyBVR!7d`;ar+D7do)jQ}m`g$TevUD5@?*P8)voa?kEe@_hl{_h8j&5eB-5FrYW&*FHVt$ z$kRF9Nstj%KRzpjdd_9wO=4zO8ritN*NPk_9avYrsF(!4))tm{Ga#OY z(r{0buexOzu7+rw8E08Gxd`LTOID{*AC1m*6Nw@osfB%0oBF5sf<~wH1kL;sd zo)k6^VyRFU`)dt*iX^9&QtWbo6yE8XXH?`ztvpiOLgI3R+=MOBQ9=rMVgi<*CU%+d1PQQ0a1U=&b0vkF207%xU0ssI2 literal 0 HcmV?d00001 diff --git a/testProjects/android-test/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/testProjects/android-test/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000000000000000000000000000000000000..4f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wg3zPVp{+wOsxKc>)(pMupKF!Y2HoUqQ3|Yu|8lwR=?5zZuhG6J?H`bSNk_wPoM{u zSL{c@pY7+c2kck>`^q1^^gR0QB7Y?KUD{vz-uVX~;V-rW)PDcI)$_UjgVV?S?=oLR zf4}zz{#*R_{LkiJ#0RdQLNC^2Vp%JPEUvG9ra2BVZ92(p9h7Ka@!yf9(lj#}>+|u* z;^_?KWdzkM`6gqPo9;;r6&JEa)}R3X{(CWv?NvgLeOTq$cZXqf7|sPImi-7cS8DCN zGf;DVt3Am`>hH3{4-WzH43Ftx)SofNe^-#|0HdCo<+8Qs!}TZP{HH8~z5n`ExcHuT zDL1m&|DVpIy=xsLO>8k92HcmfSKhflQ0H~9=^-{#!I1g(;+44xw~=* zxvNz35vfsQE)@)Zsp*6_GjYD};Squ83<_?^SbALb{a`j<0Gn%6JY!zhp=Fg}Ga2|8 z52e1WU%^L1}15Ex0fF$e@eCT(()_P zvV?CA%#Sy08_U6VPt4EtmVQraWJX` zh=N|WQ>LgrvF~R&qOfB$!%D3cGv?;Xh_z$z7k&s4N)$WYf*k=|*jCEkO19{h_(%W4 zPuOqbCw`SeAX*R}UUsbVsgtuG?xs(#Ikx9`JZoQFz0n*7ZG@Fv@kZk`gzO$HoA9kN z8U5{-yY zvV{`&WKU2$mZeoBmiJrEdzUZAv1sRxpePdg1)F*X^Y)zp^Y*R;;z~vOv-z&)&G)JQ{m!C9cmziu1^nHA z`#`0c>@PnQ9CJKgC5NjJD8HM3|KC(g5nnCq$n0Gsu_DXk36@ql%npEye|?%RmG)

FJ$wK}0tWNB{uH;AM~i literal 0 HcmV?d00001 diff --git a/testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000000000000000000000000000000000000..948a3070fe34c611c42c0d3ad3013a0dce358be0 GIT binary patch literal 1900 zcmV-y2b1_xNk&Fw2LJ$9MM6+kP&il$0000G0001A003VA06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xti0 zB{OKfAj83~iJvmpTU|&q1^?^cIMn2RQ?jeSB95l}{DrEPTW{_gmU_pqTc)h@4T>~& zluq3)GM=xa(#^VU5}@FNqpc$?#SbVsX!~RH*5p0p@w z;~v{QMX0^bFT1!cXGM8K9FP+=9~-d~#TK#ZE{4umGT=;dfvWi?rYj;^l_Zxywze`W z^Cr{55U@*BalS}K%Czii_80e0#0#Zkhlij4-~I@}`-JFJ7$5{>LnoJSs??J8kWVl6|8A}RCGAu9^rAsfCE=2}tHwl93t0C?#+jMpvr7O3`2=tr{Hg$=HlnjVG^ewm|Js0J*kfPa6*GhtB>`fN!m#9J(sU!?(OSfzY*zS(FJ<-Vb zfAIg+`U)YaXv#sY(c--|X zEB+TVyZ%Ie4L$gi#Fc++`h6%vzsS$pjz9aLt+ZL(g;n$Dzy5=m=_TV(3H8^C{r0xd zp#a%}ht55dOq?yhwYPrtp-m1xXp;4X;)NhxxUpgP%XTLmO zcjaFva^}dP3$&sfFTIR_jC=2pHh9kpI@2(6V*GQo7Ws)`j)hd+tr@P~gR*2gO@+1? zG<`_tB+LJuF|SZ9tIec;h%}}6WClT`L>HSW?E{Hp1h^+mlbf_$9zA>!ug>NALJsO{ mU%z=YwVD?}XMya)Bp;vlyE5&E_6!fzx9pwrdz474!~g(M6R?N? literal 0 HcmV?d00001 diff --git a/testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000000000000000000000000000000000000..1b9a6956b3acdc11f40ce2bb3f6efbd845cc243f GIT binary patch literal 3918 zcmV-U53%r4Nk&FS4*&pHMM6+kP&il$0000G0001A003VA06|PpNSy@$00HoY|G(*G z+qV7x14$dSO^Re!iqt-AAIE9iwr$(CZQJL$blA4B`>;C3fBY6Q8_YSjb2%a=fc}4E zrSzssacq<^nmW|Rs93PJni30R<8w<(bK_$LO4L?!_OxLl$}K$MUEllnMK|rg=f3;y z*?;3j|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diff --git a/testProjects/android-test/app/src/main/res/values-night/themes.xml b/testProjects/android-test/app/src/main/res/values-night/themes.xml new file mode 100644 index 00000000..85765448 --- /dev/null +++ b/testProjects/android-test/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/values/colors.xml b/testProjects/android-test/app/src/main/res/values/colors.xml new file mode 100644 index 00000000..f8c6127d --- /dev/null +++ b/testProjects/android-test/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/values/strings.xml b/testProjects/android-test/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..ad0d77d4 --- /dev/null +++ b/testProjects/android-test/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + AndroidTest + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/values/themes.xml b/testProjects/android-test/app/src/main/res/values/themes.xml new file mode 100644 index 00000000..226985f2 --- /dev/null +++ b/testProjects/android-test/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/xml/backup_rules.xml b/testProjects/android-test/app/src/main/res/xml/backup_rules.xml new file mode 100644 index 00000000..fa0f996d --- /dev/null +++ b/testProjects/android-test/app/src/main/res/xml/backup_rules.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/xml/data_extraction_rules.xml b/testProjects/android-test/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 00000000..9ee9997b --- /dev/null +++ b/testProjects/android-test/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/testProjects/android-test/app/src/test/java/com/example/androidtest/ExampleUnitTest.java b/testProjects/android-test/app/src/test/java/com/example/androidtest/ExampleUnitTest.java new file mode 100644 index 00000000..b24cae29 --- /dev/null +++ b/testProjects/android-test/app/src/test/java/com/example/androidtest/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.example.androidtest; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/testProjects/android-test/build.gradle b/testProjects/android-test/build.gradle new file mode 100644 index 00000000..565f8c24 --- /dev/null +++ b/testProjects/android-test/build.gradle @@ -0,0 +1,4 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { +alias(libs.plugins.android.application) apply false +} \ No newline at end of file diff --git a/testProjects/android-test/gradle.properties b/testProjects/android-test/gradle.properties new file mode 100644 index 00000000..4387edc2 --- /dev/null +++ b/testProjects/android-test/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true \ No newline at end of file diff --git a/testProjects/android-test/gradle/libs.versions.toml b/testProjects/android-test/gradle/libs.versions.toml new file mode 100644 index 00000000..90884185 --- /dev/null +++ b/testProjects/android-test/gradle/libs.versions.toml @@ -0,0 +1,22 @@ +[versions] +agp = "8.5.1" +junit = "4.13.2" +junitVersion = "1.2.1" +espressoCore = "3.6.1" +appcompat = "1.7.0" +material = "1.12.0" +activity = "1.9.0" +constraintlayout = "2.1.4" + +[libraries] +junit = { group = "junit", name = "junit", version.ref = "junit" } +ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } +espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } +appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +material = { group = "com.google.android.material", name = "material", version.ref = "material" } +activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } +constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } + diff --git a/testProjects/android-test/gradle/wrapper/gradle-wrapper.properties b/testProjects/android-test/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..7f026d4d --- /dev/null +++ b/testProjects/android-test/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Jul 16 19:40:56 IST 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/testProjects/android-test/gradlew b/testProjects/android-test/gradlew new file mode 100644 index 00000000..4f906e0c --- /dev/null +++ b/testProjects/android-test/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or 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 +# +# https://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. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/testProjects/android-test/gradlew.bat b/testProjects/android-test/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/testProjects/android-test/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/testProjects/android-test/settings.gradle b/testProjects/android-test/settings.gradle new file mode 100644 index 00000000..90e84831 --- /dev/null +++ b/testProjects/android-test/settings.gradle @@ -0,0 +1,23 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "AndroidTest" +include ':app' From 8b2ac66d0e11e5d8b6a785d71e7cef972d013422 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Mon, 29 Jul 2024 21:56:49 +0530 Subject: [PATCH 02/15] Implemented AndroidSourceSet Retrieval Changes: - Added Android Library Module to android-test project. - Added SourceSetUtils file with methods to check for android projects and retrieve source sets. - Added unit test to GradleApiConnectorTest for android-test project. --- .../gradle/plugin/SourceSetsModelBuilder.java | 4 +- .../gradle/plugin/model/AndroidSourceSet.java | 159 ++++++++++++++++++ .../gradle/plugin/utils/SourceSetUtils.java | 88 ++++++++++ .../gradle/GradleApiConnectorTest.java | 10 ++ testProjects/android-test/build.gradle | 1 + .../android-test/gradle/libs.versions.toml | 7 + .../android-test/mylibrary/.gitignore | 1 + .../android-test/mylibrary/build.gradle | 34 ++++ .../android-test/mylibrary/consumer-rules.pro | 0 .../android-test/mylibrary/proguard-rules.pro | 21 +++ .../mylibrary/ExampleInstrumentedTest.java | 25 +++ .../mylibrary/src/main/AndroidManifest.xml | 4 + .../example/mylibrary/ExampleUnitTest.java | 17 ++ testProjects/android-test/settings.gradle | 1 + 14 files changed, 371 insertions(+), 1 deletion(-) create mode 100644 plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java create mode 100644 plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java create mode 100644 testProjects/android-test/mylibrary/.gitignore create mode 100644 testProjects/android-test/mylibrary/build.gradle create mode 100644 testProjects/android-test/mylibrary/consumer-rules.pro create mode 100644 testProjects/android-test/mylibrary/proguard-rules.pro create mode 100644 testProjects/android-test/mylibrary/src/androidTest/java/com/example/mylibrary/ExampleInstrumentedTest.java create mode 100644 testProjects/android-test/mylibrary/src/main/AndroidManifest.xml create mode 100644 testProjects/android-test/mylibrary/src/test/java/com/example/mylibrary/ExampleUnitTest.java diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java index 5b20f596..f13c34fd 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java @@ -16,6 +16,8 @@ import java.util.Set; import java.util.stream.Collectors; +import com.microsoft.java.bs.gradle.plugin.model.AndroidSourceSet; +import com.microsoft.java.bs.gradle.plugin.utils.SourceSetUtils; import org.gradle.api.GradleException; import org.gradle.api.Project; import org.gradle.api.Task; @@ -57,7 +59,7 @@ public Object buildAll(String modelName, Project project) { return new DefaultGradleSourceSets(sourceSets); } - + private DefaultGradleSourceSet getSourceSet(Project project, SourceSet sourceSet) { DefaultGradleSourceSet gradleSourceSet = new DefaultGradleSourceSet(); // dependencies are populated by the GradleSourceSetsAction. Make sure not null. diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java new file mode 100644 index 00000000..8831be6f --- /dev/null +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java @@ -0,0 +1,159 @@ +package com.microsoft.java.bs.gradle.plugin.model; + +import java.io.File; +import java.util.List; +import java.util.Set; + +public class AndroidSourceSet { + + private String name; + private Set aidlDirectories; + private Set assetsDirectories; + private Set cppDirectories; + private List customDirectories; + private Set javaDirectories; + private Set kotlinDirectories; + private File manifestFile; + private Set mlModelDirectories; + private Set renderScriptDirectories; + private Set resDirectories; + private Set resourceDirectories; + private Set shaderDirectories; + + public AndroidSourceSet() { + } + + public AndroidSourceSet( + String name, + Set aidlDirectories, + Set assetsDirectories, + Set cppDirectories, + List customDirectories, + Set javaDirectories, + Set kotlinDirectories, + File manifestFile, + Set mlModelDirectories, + Set renderScriptDirectories, + Set resDirectories, + Set resourceDirectories, + Set shaderDirectories + ) { + this.name = name; + this.aidlDirectories = aidlDirectories; + this.assetsDirectories = assetsDirectories; + this.cppDirectories = cppDirectories; + this.customDirectories = customDirectories; + this.javaDirectories = javaDirectories; + this.kotlinDirectories = kotlinDirectories; + this.manifestFile = manifestFile; + this.mlModelDirectories = mlModelDirectories; + this.renderScriptDirectories = renderScriptDirectories; + this.resDirectories = resDirectories; + this.resourceDirectories = resourceDirectories; + this.shaderDirectories = shaderDirectories; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Set getAidlDirectories() { + return aidlDirectories; + } + + public void setAidlDirectories(Set aidlDirectories) { + this.aidlDirectories = aidlDirectories; + } + + public Set getAssetsDirectories() { + return assetsDirectories; + } + + public void setAssetsDirectories(Set assetsDirectories) { + this.assetsDirectories = assetsDirectories; + } + + public Set getCppDirectories() { + return cppDirectories; + } + + public void setCppDirectories(Set cppDirectories) { + this.cppDirectories = cppDirectories; + } + + public List getCustomDirectories() { + return customDirectories; + } + + public void setCustomDirectories(List customDirectories) { + this.customDirectories = customDirectories; + } + + public Set getJavaDirectories() { + return javaDirectories; + } + + public void setJavaDirectories(Set javaDirectories) { + this.javaDirectories = javaDirectories; + } + + public Set getKotlinDirectories() { + return kotlinDirectories; + } + + public void setKotlinDirectories(Set kotlinDirectories) { + this.kotlinDirectories = kotlinDirectories; + } + + public File getManifestFile() { + return manifestFile; + } + + public void setManifestFile(File manifestFile) { + this.manifestFile = manifestFile; + } + + public Set getMlModelDirectories() { + return mlModelDirectories; + } + + public void setMlModelDirectories(Set mlModelDirectories) { + this.mlModelDirectories = mlModelDirectories; + } + + public Set getRenderScriptDirectories() { + return renderScriptDirectories; + } + + public void setRenderScriptDirectories(Set renderScriptDirectories) { + this.renderScriptDirectories = renderScriptDirectories; + } + + public Set getResDirectories() { + return resDirectories; + } + + public void setResDirectories(Set resDirectories) { + this.resDirectories = resDirectories; + } + + public Set getResourceDirectories() { + return resourceDirectories; + } + + public void setResourceDirectories(Set resourceDirectories) { + this.resourceDirectories = resourceDirectories; + } + + public Set getShaderDirectories() { + return shaderDirectories; + } + + public void setShaderDirectories(Set shaderDirectories) { + this.shaderDirectories = shaderDirectories; + } +} diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java new file mode 100644 index 00000000..50401e16 --- /dev/null +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java @@ -0,0 +1,88 @@ +package com.microsoft.java.bs.gradle.plugin.utils; + +import com.microsoft.java.bs.gradle.plugin.model.AndroidSourceSet; +import org.gradle.api.Project; +import org.gradle.api.UnknownDomainObjectException; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; + +public class SourceSetUtils { + + private SourceSetUtils() { + } + + public static boolean isAndroidProject(Project project) { + + try { + project.getExtensions().getByName("android"); + return true; + } catch (UnknownDomainObjectException e) { + // do nothing + } + + return false; + + } + + public static List getAndroidSourceSets(Project project) { + + try { + // TODO: Extensions not available for older gradle versions, use conventions instead? + Object androidExtension = project.getExtensions().getByName("android"); + Method getSourceSets = androidExtension.getClass().getMethod("getSourceSets"); + List sourceSets = new ArrayList<>(((Collection) getSourceSets.invoke(androidExtension))); + + List androidSourceSets = new LinkedList<>(); + for (Object sourceSet : sourceSets) { + AndroidSourceSet androidSourceSet = convertToAndroidSourceSet(sourceSet); + if (androidSourceSet != null) { + androidSourceSets.add(androidSourceSet); + } + } + return androidSourceSets; + + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { + // do nothing + } + + return new LinkedList<>(); + + } + + public static AndroidSourceSet convertToAndroidSourceSet(Object object) { + + try { + + Class clazz = object.getClass(); + + String name = (String) clazz.getMethod("getName").invoke(object); + Set aidlDirs = (Set) clazz.getMethod("getAidlDirectories").invoke(object); + Set assetsDirs = (Set) clazz.getMethod("getAssetsDirectories").invoke(object); + Set cppDirs = (Set) clazz.getMethod("getCppDirectories").invoke(object); + List customDirs = (List) clazz.getMethod("getCustomDirectories").invoke(object); + Set javaDirs = (Set) clazz.getMethod("getJavaDirectories").invoke(object); + Set kotlinDirs = (Set) clazz.getMethod("getKotlinDirectories").invoke(object); + File manifestFile = (File) clazz.getMethod("getManifestFile").invoke(object); + Set mlModelsDirs = (Set) clazz.getMethod("getMlModelsDirectories").invoke(object); + Set renderScriptDirs = (Set) clazz.getMethod("getRenderscriptDirectories").invoke(object); + Set resDirs = (Set) clazz.getMethod("getResDirectories").invoke(object); + Set resourceDirs = (Set) clazz.getMethod("getResourcesDirectories").invoke(object); + Set shaderDirs = (Set) clazz.getMethod("getShadersDirectories").invoke(object); + + return new AndroidSourceSet( + name, aidlDirs, assetsDirs, cppDirs, customDirs, javaDirs, kotlinDirs, + manifestFile, mlModelsDirs, renderScriptDirs, resDirs, resourceDirs, shaderDirs + ); + + } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { + // do nothing + } + + return null; + + } + +} diff --git a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java index 25f2de89..1c64ff90 100644 --- a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java +++ b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java @@ -92,6 +92,16 @@ void testGetGradleSourceSets() { "junit5-jupiter-starter-gradle [test]").getSourceSetName()); } + @Test + void testGetAndroidSourceSets() { + File projectDir = projectPath.resolve("android-test").toFile(); + PreferenceManager preferenceManager = new PreferenceManager(); + preferenceManager.setPreferences(new Preferences()); + GradleApiConnector connector = new GradleApiConnector(preferenceManager); + GradleSourceSets gradleSourceSets = connector.getGradleSourceSets(projectDir.toURI(), null); + // TODO: Verify if complete source sets were retrieved + } + private GradleSourceSet findSourceSet(GradleSourceSets gradleSourceSets, String displayName) { GradleSourceSet sourceSet = gradleSourceSets.getGradleSourceSets().stream() .filter(ss -> ss.getDisplayName().equals(displayName)) diff --git a/testProjects/android-test/build.gradle b/testProjects/android-test/build.gradle index 565f8c24..99e73ad4 100644 --- a/testProjects/android-test/build.gradle +++ b/testProjects/android-test/build.gradle @@ -1,4 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false } \ No newline at end of file diff --git a/testProjects/android-test/gradle/libs.versions.toml b/testProjects/android-test/gradle/libs.versions.toml index 90884185..38e0e3be 100644 --- a/testProjects/android-test/gradle/libs.versions.toml +++ b/testProjects/android-test/gradle/libs.versions.toml @@ -7,6 +7,9 @@ appcompat = "1.7.0" material = "1.12.0" activity = "1.9.0" constraintlayout = "2.1.4" +runner = "1.0.2" +espressoCoreVersion = "3.0.2" +appcompatV7 = "28.0.0" [libraries] junit = { group = "junit", name = "junit", version.ref = "junit" } @@ -16,7 +19,11 @@ appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "a material = { group = "com.google.android.material", name = "material", version.ref = "material" } activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } +runner = { group = "com.android.support.test", name = "runner", version.ref = "runner" } +android-espresso-core = { group = "com.android.support.test.espresso", name = "espresso-core", version.ref = "espressoCoreVersion" } +appcompat-v7 = { group = "com.android.support", name = "appcompat-v7", version.ref = "appcompatV7" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } +android-library = { id = "com.android.library", version.ref = "agp" } diff --git a/testProjects/android-test/mylibrary/.gitignore b/testProjects/android-test/mylibrary/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/testProjects/android-test/mylibrary/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/testProjects/android-test/mylibrary/build.gradle b/testProjects/android-test/mylibrary/build.gradle new file mode 100644 index 00000000..6bf974b8 --- /dev/null +++ b/testProjects/android-test/mylibrary/build.gradle @@ -0,0 +1,34 @@ +plugins { + alias(libs.plugins.android.library) +} + +android { + namespace 'com.example.mylibrary' + compileSdk 34 + + defaultConfig { + minSdk 26 + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation libs.appcompat.v7 + testImplementation libs.junit + androidTestImplementation libs.runner + androidTestImplementation libs.android.espresso.core +} \ No newline at end of file diff --git a/testProjects/android-test/mylibrary/consumer-rules.pro b/testProjects/android-test/mylibrary/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/testProjects/android-test/mylibrary/proguard-rules.pro b/testProjects/android-test/mylibrary/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/testProjects/android-test/mylibrary/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/testProjects/android-test/mylibrary/src/androidTest/java/com/example/mylibrary/ExampleInstrumentedTest.java b/testProjects/android-test/mylibrary/src/androidTest/java/com/example/mylibrary/ExampleInstrumentedTest.java new file mode 100644 index 00000000..d29708b8 --- /dev/null +++ b/testProjects/android-test/mylibrary/src/androidTest/java/com/example/mylibrary/ExampleInstrumentedTest.java @@ -0,0 +1,25 @@ +package com.example.mylibrary; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.mylibrary.test", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/testProjects/android-test/mylibrary/src/main/AndroidManifest.xml b/testProjects/android-test/mylibrary/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/testProjects/android-test/mylibrary/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/testProjects/android-test/mylibrary/src/test/java/com/example/mylibrary/ExampleUnitTest.java b/testProjects/android-test/mylibrary/src/test/java/com/example/mylibrary/ExampleUnitTest.java new file mode 100644 index 00000000..0c3b0847 --- /dev/null +++ b/testProjects/android-test/mylibrary/src/test/java/com/example/mylibrary/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.example.mylibrary; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/testProjects/android-test/settings.gradle b/testProjects/android-test/settings.gradle index 90e84831..be72bbfa 100644 --- a/testProjects/android-test/settings.gradle +++ b/testProjects/android-test/settings.gradle @@ -21,3 +21,4 @@ dependencyResolutionManagement { rootProject.name = "AndroidTest" include ':app' +include ':mylibrary' From 335ae82b26d052b09cac5034081253aabf0cd8f6 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Tue, 30 Jul 2024 21:45:11 +0530 Subject: [PATCH 03/15] Add C Directories and CompileClasspath properties to AndroidSourceSet and implement retrieval in SourceSetUtils. --- .../gradle/plugin/model/AndroidSourceSet.java | 25 ++++++- .../gradle/plugin/utils/SourceSetUtils.java | 65 ++++++++++++++----- 2 files changed, 71 insertions(+), 19 deletions(-) diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java index 8831be6f..899ddc74 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java @@ -9,6 +9,7 @@ public class AndroidSourceSet { private String name; private Set aidlDirectories; private Set assetsDirectories; + private Set cDirectories; private Set cppDirectories; private List customDirectories; private Set javaDirectories; @@ -19,6 +20,7 @@ public class AndroidSourceSet { private Set resDirectories; private Set resourceDirectories; private Set shaderDirectories; + private Set compileClasspath; public AndroidSourceSet() { } @@ -27,6 +29,7 @@ public AndroidSourceSet( String name, Set aidlDirectories, Set assetsDirectories, + Set cDirectories, Set cppDirectories, List customDirectories, Set javaDirectories, @@ -36,11 +39,13 @@ public AndroidSourceSet( Set renderScriptDirectories, Set resDirectories, Set resourceDirectories, - Set shaderDirectories + Set shaderDirectories, + Set compileClasspath ) { this.name = name; this.aidlDirectories = aidlDirectories; this.assetsDirectories = assetsDirectories; + this.cDirectories = cDirectories; this.cppDirectories = cppDirectories; this.customDirectories = customDirectories; this.javaDirectories = javaDirectories; @@ -51,6 +56,7 @@ public AndroidSourceSet( this.resDirectories = resDirectories; this.resourceDirectories = resourceDirectories; this.shaderDirectories = shaderDirectories; + this.compileClasspath = compileClasspath; } public String getName() { @@ -77,6 +83,14 @@ public void setAssetsDirectories(Set assetsDirectories) { this.assetsDirectories = assetsDirectories; } + public Set getCDirectories() { + return cDirectories; + } + + public void setCDirectories(Set cDirectories) { + this.cDirectories = cDirectories; + } + public Set getCppDirectories() { return cppDirectories; } @@ -156,4 +170,13 @@ public Set getShaderDirectories() { public void setShaderDirectories(Set shaderDirectories) { this.shaderDirectories = shaderDirectories; } + + public Set getCompileClasspath() { + return compileClasspath; + } + + public void setCompileClasspath(Set compileClasspath) { + this.compileClasspath = compileClasspath; + } + } diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java index 50401e16..82fa0ee5 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java @@ -3,6 +3,8 @@ import com.microsoft.java.bs.gradle.plugin.model.AndroidSourceSet; import org.gradle.api.Project; import org.gradle.api.UnknownDomainObjectException; +import org.gradle.api.artifacts.Configuration; +import org.gradle.util.GradleVersion; import java.io.File; import java.lang.reflect.InvocationTargetException; @@ -16,43 +18,40 @@ private SourceSetUtils() { public static boolean isAndroidProject(Project project) { - try { - project.getExtensions().getByName("android"); - return true; - } catch (UnknownDomainObjectException e) { - // do nothing - } - - return false; + return getProjectExtension(project, "android") != null; } public static List getAndroidSourceSets(Project project) { + List androidSourceSets = new LinkedList<>(); + + Object androidExtension = getProjectExtension(project, "android"); + if (androidExtension == null) { + return androidSourceSets; + } + try { - // TODO: Extensions not available for older gradle versions, use conventions instead? - Object androidExtension = project.getExtensions().getByName("android"); + Method getSourceSets = androidExtension.getClass().getMethod("getSourceSets"); List sourceSets = new ArrayList<>(((Collection) getSourceSets.invoke(androidExtension))); - List androidSourceSets = new LinkedList<>(); for (Object sourceSet : sourceSets) { - AndroidSourceSet androidSourceSet = convertToAndroidSourceSet(sourceSet); + AndroidSourceSet androidSourceSet = convertToAndroidSourceSet(sourceSet, project); if (androidSourceSet != null) { androidSourceSets.add(androidSourceSet); } } - return androidSourceSets; - } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException | UnknownDomainObjectException e) { // do nothing } - return new LinkedList<>(); + return androidSourceSets; } - public static AndroidSourceSet convertToAndroidSourceSet(Object object) { + public static AndroidSourceSet convertToAndroidSourceSet(Object object, Project project) { try { @@ -61,6 +60,7 @@ public static AndroidSourceSet convertToAndroidSourceSet(Object object) { String name = (String) clazz.getMethod("getName").invoke(object); Set aidlDirs = (Set) clazz.getMethod("getAidlDirectories").invoke(object); Set assetsDirs = (Set) clazz.getMethod("getAssetsDirectories").invoke(object); + Set cDirs = (Set) clazz.getMethod("getCDirectories").invoke(object); Set cppDirs = (Set) clazz.getMethod("getCppDirectories").invoke(object); List customDirs = (List) clazz.getMethod("getCustomDirectories").invoke(object); Set javaDirs = (Set) clazz.getMethod("getJavaDirectories").invoke(object); @@ -72,9 +72,17 @@ public static AndroidSourceSet convertToAndroidSourceSet(Object object) { Set resourceDirs = (Set) clazz.getMethod("getResourcesDirectories").invoke(object); Set shaderDirs = (Set) clazz.getMethod("getShadersDirectories").invoke(object); + Set classpath = new HashSet<>(); + String compileConfigName = (String) clazz.getMethod("getCompileConfigurationName").invoke(object); + + Configuration compileConfig = project.getConfigurations().findByName(compileConfigName); + if (compileConfig != null) { + classpath.addAll(compileConfig.getFiles()); + } + return new AndroidSourceSet( - name, aidlDirs, assetsDirs, cppDirs, customDirs, javaDirs, kotlinDirs, - manifestFile, mlModelsDirs, renderScriptDirs, resDirs, resourceDirs, shaderDirs + name, aidlDirs, assetsDirs, cDirs, cppDirs, customDirs, javaDirs, kotlinDirs, manifestFile, + mlModelsDirs, renderScriptDirs, resDirs, resourceDirs, shaderDirs, classpath ); } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { @@ -85,4 +93,25 @@ public static AndroidSourceSet convertToAndroidSourceSet(Object object) { } + public static Object getProjectExtension(Project project, String extensionName) { + + Object extension = null; + + try { + if (GradleVersion.current().compareTo(GradleVersion.version("5.0")) >= 0) { + // Extension is supported + extension = project.getExtensions().findByName(extensionName); + } else { + // Fallback to Convention + Object convention = project.getClass().getMethod("getConvention").invoke(project); + extension = convention.getClass().getMethod("getByName").invoke(convention, extensionName); + } + } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { + // do nothing + } + + return extension; + + } + } From 2fe5eda146578519c9374f348df3f1ca8f6e01c1 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:31:33 +0530 Subject: [PATCH 04/15] Added methods and classes to retrieve AndroidVariants. --- .../gradle/plugin/model/AndroidSourceSet.java | 1 - .../gradle/plugin/model/AndroidVariant.java | 241 ++++++++++++++++++ .../gradle/plugin/utils/SourceSetUtils.java | 131 +++++++++- .../gradle/GradleApiConnectorTest.java | 1 + 4 files changed, 359 insertions(+), 15 deletions(-) create mode 100644 plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidVariant.java diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java index 899ddc74..c1618855 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java @@ -56,7 +56,6 @@ public AndroidSourceSet( this.resDirectories = resDirectories; this.resourceDirectories = resourceDirectories; this.shaderDirectories = shaderDirectories; - this.compileClasspath = compileClasspath; } public String getName() { diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidVariant.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidVariant.java new file mode 100644 index 00000000..aaea119c --- /dev/null +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidVariant.java @@ -0,0 +1,241 @@ +package com.microsoft.java.bs.gradle.plugin.model; + +import com.microsoft.java.bs.gradle.model.BuildTargetDependency; +import com.microsoft.java.bs.gradle.model.GradleModuleDependency; +import com.microsoft.java.bs.gradle.model.LanguageExtension; + +import java.io.File; +import java.util.Map; +import java.util.Set; + +public class AndroidVariant { + + private String gradleVersion; + private String displayName; + private String projectName; + private String projectPath; + private File projectDir; + private File rootDir; + private String variantName; + private String classesTaskName; + private String cleanTaskName; + private Set taskNames; + private Set sourceDirs; + private Set generatedSourceDirs; + private File sourceOutputDir; + private Set resourceDirs; + private File resourceOutputDir; + private Set compileClasspath; + private Set moduleDependencies; + private Set buildTargetDependencies; + private boolean hasTests; + private Map extensions; + + public AndroidVariant() { + } + + public AndroidVariant( + String gradleVersion, + String displayName, + String projectName, + String projectPath, + File projectDir, + File rootDir, + String variantName, + String classesTaskName, + String cleanTaskName, + Set taskNames, + Set sourceDirs, + Set generatedSourceDirs, + File sourceOutputDir, + Set resourceDirs, + File resourceOutputDir, + Set compileClasspath, + Set moduleDependencies, + Set buildTargetDependencies, + boolean hasTests, + Map extensions + ) { + this.gradleVersion = gradleVersion; + this.displayName = displayName; + this.projectName = projectName; + this.projectPath = projectPath; + this.projectDir = projectDir; + this.rootDir = rootDir; + this.variantName = variantName; + this.classesTaskName = classesTaskName; + this.cleanTaskName = cleanTaskName; + this.taskNames = taskNames; + this.sourceDirs = sourceDirs; + this.generatedSourceDirs = generatedSourceDirs; + this.sourceOutputDir = sourceOutputDir; + this.resourceDirs = resourceDirs; + this.resourceOutputDir = resourceOutputDir; + this.compileClasspath = compileClasspath; + this.moduleDependencies = moduleDependencies; + this.buildTargetDependencies = buildTargetDependencies; + this.hasTests = hasTests; + this.extensions = extensions; + } + + public String getGradleVersion() { + return gradleVersion; + } + + public void setGradleVersion(String gradleVersion) { + this.gradleVersion = gradleVersion; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public String getProjectPath() { + return projectPath; + } + + public void setProjectPath(String projectPath) { + this.projectPath = projectPath; + } + + public File getProjectDir() { + return projectDir; + } + + public void setProjectDir(File projectDir) { + this.projectDir = projectDir; + } + + public File getRootDir() { + return rootDir; + } + + public void setRootDir(File rootDir) { + this.rootDir = rootDir; + } + + public String getVariantName() { + return variantName; + } + + public void setVariantName(String variantName) { + this.variantName = variantName; + } + + public String getClassesTaskName() { + return classesTaskName; + } + + public void setClassesTaskName(String classesTaskName) { + this.classesTaskName = classesTaskName; + } + + public String getCleanTaskName() { + return cleanTaskName; + } + + public void setCleanTaskName(String cleanTaskName) { + this.cleanTaskName = cleanTaskName; + } + + public Set getTaskNames() { + return taskNames; + } + + public void setTaskNames(Set taskNames) { + this.taskNames = taskNames; + } + + public Set getSourceDirs() { + return sourceDirs; + } + + public void setSourceDirs(Set sourceDirs) { + this.sourceDirs = sourceDirs; + } + + public Set getGeneratedSourceDirs() { + return generatedSourceDirs; + } + + public void setGeneratedSourceDirs(Set generatedSourceDirs) { + this.generatedSourceDirs = generatedSourceDirs; + } + + public File getSourceOutputDir() { + return sourceOutputDir; + } + + public void setSourceOutputDir(File sourceOutputDir) { + this.sourceOutputDir = sourceOutputDir; + } + + public Set getResourceDirs() { + return resourceDirs; + } + + public void setResourceDirs(Set resourceDirs) { + this.resourceDirs = resourceDirs; + } + + public File getResourceOutputDir() { + return resourceOutputDir; + } + + public void setResourceOutputDir(File resourceOutputDir) { + this.resourceOutputDir = resourceOutputDir; + } + + public Set getCompileClasspath() { + return compileClasspath; + } + + public void setCompileClasspath(Set compileClasspath) { + this.compileClasspath = compileClasspath; + } + + public Set getModuleDependencies() { + return moduleDependencies; + } + + public void setModuleDependencies(Set moduleDependencies) { + this.moduleDependencies = moduleDependencies; + } + + public Set getBuildTargetDependencies() { + return buildTargetDependencies; + } + + public void setBuildTargetDependencies(Set buildTargetDependencies) { + this.buildTargetDependencies = buildTargetDependencies; + } + + public boolean isHasTests() { + return hasTests; + } + + public void setHasTests(boolean hasTests) { + this.hasTests = hasTests; + } + + public Map getExtensions() { + return extensions; + } + + public void setExtensions(Map extensions) { + this.extensions = extensions; + } + +} diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java index 82fa0ee5..266bc01c 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java @@ -1,10 +1,10 @@ package com.microsoft.java.bs.gradle.plugin.utils; import com.microsoft.java.bs.gradle.plugin.model.AndroidSourceSet; +import com.microsoft.java.bs.gradle.plugin.model.AndroidVariant; import org.gradle.api.Project; import org.gradle.api.UnknownDomainObjectException; import org.gradle.api.artifacts.Configuration; -import org.gradle.util.GradleVersion; import java.io.File; import java.lang.reflect.InvocationTargetException; @@ -17,8 +17,83 @@ private SourceSetUtils() { } public static boolean isAndroidProject(Project project) { - return getProjectExtension(project, "android") != null; + } + + public static List getAndroidBuildVariants(Project project) { + + List androidBuildVariants = new LinkedList<>(); + + Object androidExtension = getProjectExtension(project, "android"); + if (androidExtension == null) { + return androidBuildVariants; + } + + AndroidProjectType type = getProjectType(project); + if (type == null) { + return androidBuildVariants; + } + + String methodName = ""; + switch (type) { + case APPLICATION: + case DYNAMIC_FEATURE: + methodName = "getApplicationVariants"; + break; + case LIBRARY: + methodName = "getLibraryVariants"; + break; + case INSTANT_APP_FEATURE: + methodName = "getFeatureVariants"; + break; + case ANDROID_TEST: + methodName = "getTestVariants"; + break; + } + + try { + Set variants = (Set) androidExtension.getClass().getMethod(methodName).invoke(androidExtension); + for (Object variant : variants) { + AndroidVariant androidVariant = convertToAndroidVariant(project, variant); + if (androidVariant == null) { + continue; + } + androidBuildVariants.add(androidVariant); + } + } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | ClassCastException e) { + // do nothing + androidBuildVariants.size(); + } + + return androidBuildVariants; + + } + + public static AndroidVariant convertToAndroidVariant(Project project, Object variant) { + + try { + + AndroidVariant androidVariant = new AndroidVariant(); + + androidVariant.setGradleVersion(project.getGradle().getGradleVersion()); + androidVariant.setProjectName(project.getName()); + androidVariant.setDisplayName(project.getDisplayName()); + androidVariant.setProjectPath(project.getPath()); + androidVariant.setProjectDir(project.getProjectDir()); + androidVariant.setRootDir(project.getRootDir()); + + String variantName = (String) variant.getClass().getMethod("getName").invoke(variant); + androidVariant.setVariantName(variantName); + + Object compileConfig = variant.getClass().getMethod("getCompileConfiguration").invoke(variant); + Set classpathFiles = (Set) compileConfig.getClass().getMethod("getFiles").invoke(compileConfig); + androidVariant.setCompileClasspath(classpathFiles); + + return androidVariant; + + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + return null; + } } @@ -37,13 +112,14 @@ public static List getAndroidSourceSets(Project project) { List sourceSets = new ArrayList<>(((Collection) getSourceSets.invoke(androidExtension))); for (Object sourceSet : sourceSets) { - AndroidSourceSet androidSourceSet = convertToAndroidSourceSet(sourceSet, project); + AndroidSourceSet androidSourceSet = convertToAndroidSourceSet(project, sourceSet); if (androidSourceSet != null) { androidSourceSets.add(androidSourceSet); } } - } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException | UnknownDomainObjectException e) { + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException | + UnknownDomainObjectException e) { // do nothing } @@ -51,7 +127,7 @@ public static List getAndroidSourceSets(Project project) { } - public static AndroidSourceSet convertToAndroidSourceSet(Object object, Project project) { + public static AndroidSourceSet convertToAndroidSourceSet(Project project, Object object) { try { @@ -98,15 +174,10 @@ public static Object getProjectExtension(Project project, String extensionName) Object extension = null; try { - if (GradleVersion.current().compareTo(GradleVersion.version("5.0")) >= 0) { - // Extension is supported - extension = project.getExtensions().findByName(extensionName); - } else { - // Fallback to Convention - Object convention = project.getClass().getMethod("getConvention").invoke(project); - extension = convention.getClass().getMethod("getByName").invoke(convention, extensionName); - } - } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { + Object convention = project.getClass().getMethod("getConvention").invoke(project); + Object extensionMap = convention.getClass().getMethod("getAsMap").invoke(convention); + extension = extensionMap.getClass().getMethod("get", Object.class).invoke(extensionMap, extensionName); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { // do nothing } @@ -114,4 +185,36 @@ public static Object getProjectExtension(Project project, String extensionName) } + public static AndroidProjectType getProjectType(Project project) { + + if (getProjectExtension(project, "android") == null) { + return null; + } + + AndroidProjectType projectType = null; + + if (project.getPluginManager().hasPlugin("com.android.application")) { + projectType = AndroidProjectType.APPLICATION; + } else if (project.getPluginManager().hasPlugin("com.android.library")) { + projectType = AndroidProjectType.LIBRARY; + } else if (project.getPluginManager().hasPlugin("com.android.dynamic-feature")) { + projectType = AndroidProjectType.DYNAMIC_FEATURE; + } else if (project.getPluginManager().hasPlugin("com.android.feature")) { + projectType = AndroidProjectType.INSTANT_APP_FEATURE; + } else if (project.getPluginManager().hasPlugin("com.android.test")) { + projectType = AndroidProjectType.ANDROID_TEST; + } + + return projectType; + + } + + public enum AndroidProjectType { + APPLICATION, + LIBRARY, + DYNAMIC_FEATURE, + INSTANT_APP_FEATURE, + ANDROID_TEST + } + } diff --git a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java index 1c64ff90..b3dfdb49 100644 --- a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java +++ b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java @@ -99,6 +99,7 @@ void testGetAndroidSourceSets() { preferenceManager.setPreferences(new Preferences()); GradleApiConnector connector = new GradleApiConnector(preferenceManager); GradleSourceSets gradleSourceSets = connector.getGradleSourceSets(projectDir.toURI(), null); + assertEquals(4, gradleSourceSets.getGradleSourceSets().size()); // TODO: Verify if complete source sets were retrieved } From bbbde865998445664905177ff50e2702598aab1f Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:49:34 +0530 Subject: [PATCH 05/15] Refactored SourceSetUtils and prepared for android testing. --- .../gradle/plugin/model/AndroidSourceSet.java | 181 ------------------ .../gradle/plugin/utils/SourceSetUtils.java | 102 +++------- .../internal/services/BuildTargetService.java | 167 ++++++++++------ 3 files changed, 138 insertions(+), 312 deletions(-) delete mode 100644 plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java deleted file mode 100644 index c1618855..00000000 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidSourceSet.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.microsoft.java.bs.gradle.plugin.model; - -import java.io.File; -import java.util.List; -import java.util.Set; - -public class AndroidSourceSet { - - private String name; - private Set aidlDirectories; - private Set assetsDirectories; - private Set cDirectories; - private Set cppDirectories; - private List customDirectories; - private Set javaDirectories; - private Set kotlinDirectories; - private File manifestFile; - private Set mlModelDirectories; - private Set renderScriptDirectories; - private Set resDirectories; - private Set resourceDirectories; - private Set shaderDirectories; - private Set compileClasspath; - - public AndroidSourceSet() { - } - - public AndroidSourceSet( - String name, - Set aidlDirectories, - Set assetsDirectories, - Set cDirectories, - Set cppDirectories, - List customDirectories, - Set javaDirectories, - Set kotlinDirectories, - File manifestFile, - Set mlModelDirectories, - Set renderScriptDirectories, - Set resDirectories, - Set resourceDirectories, - Set shaderDirectories, - Set compileClasspath - ) { - this.name = name; - this.aidlDirectories = aidlDirectories; - this.assetsDirectories = assetsDirectories; - this.cDirectories = cDirectories; - this.cppDirectories = cppDirectories; - this.customDirectories = customDirectories; - this.javaDirectories = javaDirectories; - this.kotlinDirectories = kotlinDirectories; - this.manifestFile = manifestFile; - this.mlModelDirectories = mlModelDirectories; - this.renderScriptDirectories = renderScriptDirectories; - this.resDirectories = resDirectories; - this.resourceDirectories = resourceDirectories; - this.shaderDirectories = shaderDirectories; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Set getAidlDirectories() { - return aidlDirectories; - } - - public void setAidlDirectories(Set aidlDirectories) { - this.aidlDirectories = aidlDirectories; - } - - public Set getAssetsDirectories() { - return assetsDirectories; - } - - public void setAssetsDirectories(Set assetsDirectories) { - this.assetsDirectories = assetsDirectories; - } - - public Set getCDirectories() { - return cDirectories; - } - - public void setCDirectories(Set cDirectories) { - this.cDirectories = cDirectories; - } - - public Set getCppDirectories() { - return cppDirectories; - } - - public void setCppDirectories(Set cppDirectories) { - this.cppDirectories = cppDirectories; - } - - public List getCustomDirectories() { - return customDirectories; - } - - public void setCustomDirectories(List customDirectories) { - this.customDirectories = customDirectories; - } - - public Set getJavaDirectories() { - return javaDirectories; - } - - public void setJavaDirectories(Set javaDirectories) { - this.javaDirectories = javaDirectories; - } - - public Set getKotlinDirectories() { - return kotlinDirectories; - } - - public void setKotlinDirectories(Set kotlinDirectories) { - this.kotlinDirectories = kotlinDirectories; - } - - public File getManifestFile() { - return manifestFile; - } - - public void setManifestFile(File manifestFile) { - this.manifestFile = manifestFile; - } - - public Set getMlModelDirectories() { - return mlModelDirectories; - } - - public void setMlModelDirectories(Set mlModelDirectories) { - this.mlModelDirectories = mlModelDirectories; - } - - public Set getRenderScriptDirectories() { - return renderScriptDirectories; - } - - public void setRenderScriptDirectories(Set renderScriptDirectories) { - this.renderScriptDirectories = renderScriptDirectories; - } - - public Set getResDirectories() { - return resDirectories; - } - - public void setResDirectories(Set resDirectories) { - this.resDirectories = resDirectories; - } - - public Set getResourceDirectories() { - return resourceDirectories; - } - - public void setResourceDirectories(Set resourceDirectories) { - this.resourceDirectories = resourceDirectories; - } - - public Set getShaderDirectories() { - return shaderDirectories; - } - - public void setShaderDirectories(Set shaderDirectories) { - this.shaderDirectories = shaderDirectories; - } - - public Set getCompileClasspath() { - return compileClasspath; - } - - public void setCompileClasspath(Set compileClasspath) { - this.compileClasspath = compileClasspath; - } - -} diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java index 266bc01c..dfe8c6d1 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java @@ -1,14 +1,12 @@ package com.microsoft.java.bs.gradle.plugin.utils; -import com.microsoft.java.bs.gradle.plugin.model.AndroidSourceSet; import com.microsoft.java.bs.gradle.plugin.model.AndroidVariant; import org.gradle.api.Project; -import org.gradle.api.UnknownDomainObjectException; -import org.gradle.api.artifacts.Configuration; +import org.gradle.api.Task; +import org.gradle.api.provider.Provider; import java.io.File; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.*; public class SourceSetUtils { @@ -20,6 +18,7 @@ public static boolean isAndroidProject(Project project) { return getProjectExtension(project, "android") != null; } + @SuppressWarnings("unchecked") public static List getAndroidBuildVariants(Project project) { List androidBuildVariants = new LinkedList<>(); @@ -62,13 +61,13 @@ public static List getAndroidBuildVariants(Project project) { } } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | ClassCastException e) { // do nothing - androidBuildVariants.size(); } return androidBuildVariants; } + @SuppressWarnings("unchecked") public static AndroidVariant convertToAndroidVariant(Project project, Object variant) { try { @@ -85,88 +84,40 @@ public static AndroidVariant convertToAndroidVariant(Project project, Object var String variantName = (String) variant.getClass().getMethod("getName").invoke(variant); androidVariant.setVariantName(variantName); + // classpath Object compileConfig = variant.getClass().getMethod("getCompileConfiguration").invoke(variant); Set classpathFiles = (Set) compileConfig.getClass().getMethod("getFiles").invoke(compileConfig); androidVariant.setCompileClasspath(classpathFiles); - return androidVariant; - - } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - return null; - } - - } - - public static List getAndroidSourceSets(Project project) { - - List androidSourceSets = new LinkedList<>(); - - Object androidExtension = getProjectExtension(project, "android"); - if (androidExtension == null) { - return androidSourceSets; - } - - try { - - Method getSourceSets = androidExtension.getClass().getMethod("getSourceSets"); - List sourceSets = new ArrayList<>(((Collection) getSourceSets.invoke(androidExtension))); - - for (Object sourceSet : sourceSets) { - AndroidSourceSet androidSourceSet = convertToAndroidSourceSet(project, sourceSet); - if (androidSourceSet != null) { - androidSourceSets.add(androidSourceSet); + // source + Object sourceSets = getProperty(variant, "sourceSets"); + Set sourceDirs = new HashSet<>(); + if (sourceSets instanceof Iterable) { + for (Object sourceSet : (Iterable) sourceSets) { + Set javaDirs = (Set) getProperty(sourceSet, "javaDirectories"); + sourceDirs.addAll(javaDirs); } } + androidVariant.setSourceDirs(sourceDirs); - } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException | - UnknownDomainObjectException e) { - // do nothing - } - - return androidSourceSets; + // generated source + Set generatedOutputs = new HashSet<>(); - } - - public static AndroidSourceSet convertToAndroidSourceSet(Project project, Object object) { + Provider javaCompileTask = (Provider) getProperty(variant, "javaCompileProvider"); + if (javaCompileTask != null) { + generatedOutputs.addAll(javaCompileTask.get().getOutputs().getFiles().getFiles()); + } - try { + androidVariant.setGeneratedSourceDirs(generatedOutputs); - Class clazz = object.getClass(); - - String name = (String) clazz.getMethod("getName").invoke(object); - Set aidlDirs = (Set) clazz.getMethod("getAidlDirectories").invoke(object); - Set assetsDirs = (Set) clazz.getMethod("getAssetsDirectories").invoke(object); - Set cDirs = (Set) clazz.getMethod("getCDirectories").invoke(object); - Set cppDirs = (Set) clazz.getMethod("getCppDirectories").invoke(object); - List customDirs = (List) clazz.getMethod("getCustomDirectories").invoke(object); - Set javaDirs = (Set) clazz.getMethod("getJavaDirectories").invoke(object); - Set kotlinDirs = (Set) clazz.getMethod("getKotlinDirectories").invoke(object); - File manifestFile = (File) clazz.getMethod("getManifestFile").invoke(object); - Set mlModelsDirs = (Set) clazz.getMethod("getMlModelsDirectories").invoke(object); - Set renderScriptDirs = (Set) clazz.getMethod("getRenderscriptDirectories").invoke(object); - Set resDirs = (Set) clazz.getMethod("getResDirectories").invoke(object); - Set resourceDirs = (Set) clazz.getMethod("getResourcesDirectories").invoke(object); - Set shaderDirs = (Set) clazz.getMethod("getShadersDirectories").invoke(object); - - Set classpath = new HashSet<>(); - String compileConfigName = (String) clazz.getMethod("getCompileConfigurationName").invoke(object); - - Configuration compileConfig = project.getConfigurations().findByName(compileConfigName); - if (compileConfig != null) { - classpath.addAll(compileConfig.getFiles()); - } + // source output - return new AndroidSourceSet( - name, aidlDirs, assetsDirs, cDirs, cppDirs, customDirs, javaDirs, kotlinDirs, manifestFile, - mlModelsDirs, renderScriptDirs, resDirs, resourceDirs, shaderDirs, classpath - ); + return androidVariant; - } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { - // do nothing + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + return null; } - return null; - } public static Object getProjectExtension(Project project, String extensionName) { @@ -209,6 +160,11 @@ public static AndroidProjectType getProjectType(Project project) { } + private static Object getProperty(Object obj, String propertyName) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + return obj.getClass().getMethod("getProperty", String.class).invoke(obj, propertyName); + } + public enum AndroidProjectType { APPLICATION, LIBRARY, diff --git a/server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java b/server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java index 50f2c39a..70143c1e 100644 --- a/server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java +++ b/server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java @@ -488,68 +488,23 @@ public TestResult buildTargetTest(TestParams params) { TestResult testResult = new TestResult(StatusCode.OK); testResult.setOriginId(params.getOriginId()); // running tests can trigger compilation that must be reported on - CompileProgressReporter compileProgressReporter = new CompileProgressReporter(client, - params.getOriginId(), getFullTaskPathMap()); - Map> groupedTargets = - groupBuildTargetsByRootDir(params.getTargets()); + CompileProgressReporter compileProgressReporter = new CompileProgressReporter(client, params.getOriginId(), getFullTaskPathMap()); + Map> groupedTargets = groupBuildTargetsByRootDir(params.getTargets()); + for (Map.Entry> entry : groupedTargets.entrySet()) { // TODO ideally BSP would have a jvmTestEnv style testkind for executing tests, not scala. StatusCode statusCode; - if (TestParamsDataKind.SCALA_TEST.equals(params.getDataKind())) { - // ScalaTestParams is for a list of classes only - ScalaTestParams testParams = JsonUtils.toModel(params.getData(), ScalaTestParams.class); - Map>> testClasses = new HashMap<>(); - for (ScalaTestClassesItem testClassesItem : testParams.getTestClasses()) { - Map> classesMethods = new HashMap<>(); - for (String classNames : testClassesItem.getClasses()) { - classesMethods.put(classNames, null); - } - testClasses.put(testClassesItem.getTarget(), classesMethods); - } - statusCode = connector.runTests(entry.getKey(), testClasses, testParams.getJvmOptions(), - params.getArguments(), null, client, params.getOriginId(), - compileProgressReporter); + + // check if targets are android + boolean isAndroid = checkIfAndroidProject(entry.getValue()); + + if (isAndroid) { + statusCode = runAndroidTests(entry, params, compileProgressReporter); + } else if (TestParamsDataKind.SCALA_TEST.equals(params.getDataKind())) { + // existing logic for scala test (class level) + statusCode = runScalaTests(entry, params, compileProgressReporter); } else if ("scala-test-suites-selection".equals(params.getDataKind())) { - // ScalaTestSuites is for a list of classes + methods - // Since it doesn't supply the specific BuildTarget we require a single - // build target in the params and reject any request that doesn't match this - if (params.getTargets().size() != 1) { - LOGGER.warning("Test params with Test Data Kind " + params.getDataKind() - + " must contain only 1 build target"); - statusCode = StatusCode.ERROR; - } else { - ScalaTestSuites testSuites = JsonUtils.toModel(params.getData(), ScalaTestSuites.class); - Map envVars = null; - boolean argsValid = true; - if (testSuites.getEnvironmentVariables() != null) { - // arg is of the form KEY=VALUE - List splitArgs = testSuites.getEnvironmentVariables() - .stream() - .map(arg -> arg.split("=")) - .collect(Collectors.toList()); - argsValid = splitArgs.stream().allMatch(arg -> arg.length == 2); - if (argsValid) { - envVars = splitArgs.stream().collect(Collectors.toMap(arg -> arg[0], arg -> arg[1])); - } - } - if (!argsValid) { - LOGGER.warning("Test params arguments must each be in the form KEY=VALUE. " - + testSuites.getEnvironmentVariables()); - statusCode = StatusCode.ERROR; - } else { - Map> classesMethods = new HashMap<>(); - for (ScalaTestSuiteSelection testSuiteSelection : testSuites.getSuites()) { - Set methods = classesMethods - .computeIfAbsent(testSuiteSelection.getClassName(), k -> new HashSet<>()); - methods.addAll(testSuiteSelection.getTests()); - } - Map>> testClasses = new HashMap<>(); - testClasses.put(params.getTargets().get(0), classesMethods); - statusCode = connector.runTests(entry.getKey(), testClasses, testSuites.getJvmOptions(), - params.getArguments(), envVars, client, params.getOriginId(), - compileProgressReporter); - } - } + statusCode = runScalaTestSuitesSelection(entry, params, compileProgressReporter); } else { LOGGER.warning("Test Data Kind " + params.getDataKind() + " not supported"); statusCode = StatusCode.ERROR; @@ -559,9 +514,105 @@ public TestResult buildTargetTest(TestParams params) { testResult.setStatusCode(statusCode); } } + return testResult; } + private boolean checkIfAndroidProject(Set targets) { + // Logic to determine if the given targets are part of an Android Project + // This might involve checking the project type, build configuration, or specific Android build targets. + return targets.stream().anyMatch(this::isAndroidProject); + } + + private boolean isAndroidProject(BuildTargetIdentifier target) { + // TODO: Have GradleBuildTarget or the source set store type of project - java, scala, android, etc. + return false; + } + + private StatusCode runAndroidTests(Map.Entry> entry, TestParams params, CompileProgressReporter compileProgressReporter) { + // Logic to run tests: + // - Determine if unit tests or instrumentation tests are to be run. + // - If instrumentation tests, ensure an emulator/device is available and handle APK installation and execution. + // - Execute the tests and capture results. + + if (isUnitTest(entry)) { + // Run Android unit tests (similar to JVM tests) + return runScalaTests(entry, params, compileProgressReporter); + } else { + // Run instrumentation tests + return runInstrumentationTests(entry, params, compileProgressReporter); + } + } + + private boolean isUnitTest(Map.Entry> entry) { + // TODO: Check if the android test is a JVM unit test + return false; + } + + private StatusCode runInstrumentationTests(Map.Entry> targets, TestParams params, CompileProgressReporter compileProgressReporter) { + // Invoke AGP to run instrumentation test + return StatusCode.OK; + } + + private StatusCode runScalaTests(Map.Entry> entry, TestParams params, CompileProgressReporter compileProgressReporter) { + // ScalaTestParams is for a list of classes only + ScalaTestParams testParams = JsonUtils.toModel(params.getData(), ScalaTestParams.class); + Map>> testClasses = new HashMap<>(); + for (ScalaTestClassesItem testClassesItem : testParams.getTestClasses()) { + Map> classesMethods = new HashMap<>(); + for (String classNames : testClassesItem.getClasses()) { + classesMethods.put(classNames, null); + } + testClasses.put(testClassesItem.getTarget(), classesMethods); + } + return connector.runTests(entry.getKey(), testClasses, testParams.getJvmOptions(), + params.getArguments(), null, client, params.getOriginId(), + compileProgressReporter); + } + + private StatusCode runScalaTestSuitesSelection(Map.Entry> entry, TestParams params, CompileProgressReporter compileProgressReporter) { + // ScalaTestSuites is for a list of classes + methods + // Since it doesn't supply the specific BuildTarget we require a single + // build target in the params and reject any request that doesn't match this + if (params.getTargets().size() != 1) { + LOGGER.warning("Test params with Test Data Kind " + params.getDataKind() + + " must contain only 1 build target"); + return StatusCode.ERROR; + } else { + ScalaTestSuites testSuites = JsonUtils.toModel(params.getData(), ScalaTestSuites.class); + Map envVars = null; + boolean argsValid = true; + if (testSuites.getEnvironmentVariables() != null) { + // arg is of the form KEY=VALUE + List splitArgs = testSuites.getEnvironmentVariables() + .stream() + .map(arg -> arg.split("=")) + .collect(Collectors.toList()); + argsValid = splitArgs.stream().allMatch(arg -> arg.length == 2); + if (argsValid) { + envVars = splitArgs.stream().collect(Collectors.toMap(arg -> arg[0], arg -> arg[1])); + } + } + if (!argsValid) { + LOGGER.warning("Test params arguments must each be in the form KEY=VALUE. " + + testSuites.getEnvironmentVariables()); + return StatusCode.ERROR; + } else { + Map> classesMethods = new HashMap<>(); + for (ScalaTestSuiteSelection testSuiteSelection : testSuites.getSuites()) { + Set methods = classesMethods + .computeIfAbsent(testSuiteSelection.getClassName(), k -> new HashSet<>()); + methods.addAll(testSuiteSelection.getTests()); + } + Map>> testClasses = new HashMap<>(); + testClasses.put(params.getTargets().get(0), classesMethods); + return connector.runTests(entry.getKey(), testClasses, testSuites.getJvmOptions(), + params.getArguments(), envVars, client, params.getOriginId(), + compileProgressReporter); + } + } + } + /** * Group the build targets by the project root directory, * projects with the same root directory can run their tasks From a3f79a64721a88885fa87f952014d013a665e980 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:58:12 +0530 Subject: [PATCH 06/15] Refactor after rebase --- .../gradle/plugin/SourceSetsModelBuilder.java | 28 +- .../gradle/plugin/model/AndroidVariant.java | 241 ------------------ ...{SourceSetUtils.java => AndroidUtils.java} | 102 +++++--- 3 files changed, 81 insertions(+), 290 deletions(-) delete mode 100644 plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidVariant.java rename plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/{SourceSetUtils.java => AndroidUtils.java} (60%) diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java index f13c34fd..9474cd70 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java @@ -16,8 +16,7 @@ import java.util.Set; import java.util.stream.Collectors; -import com.microsoft.java.bs.gradle.plugin.model.AndroidSourceSet; -import com.microsoft.java.bs.gradle.plugin.utils.SourceSetUtils; +import com.microsoft.java.bs.gradle.plugin.utils.AndroidUtils; import org.gradle.api.GradleException; import org.gradle.api.Project; import org.gradle.api.Task; @@ -52,8 +51,14 @@ public boolean canBuild(String modelName) { @Override public Object buildAll(String modelName, Project project) { // mapping Gradle source set to our customized model. - List sourceSets = getSourceSetContainer(project).stream() - .map(ss -> getSourceSet(project, ss)).collect(Collectors.toList()); + List sourceSets; + + if (AndroidUtils.isAndroidProject(project)) { + sourceSets = AndroidUtils.getBuildVariantsAsGradleSourceSets(project); + } else { + sourceSets = getSourceSetContainer(project).stream() + .map(ss -> getSourceSet(project, ss)).collect(Collectors.toList()); + } excludeSourceDirsFromModules(sourceSets); @@ -135,7 +140,7 @@ private DefaultGradleSourceSet getSourceSet(Project project, SourceSet sourceSet gradleSourceSet.setArchiveOutputFiles(archiveOutputFiles); // tests - if (sourceOutputDirs != null) { + if (!sourceOutputDirs.isEmpty()) { Set testTasks = tasksWithType(project, Test.class); for (Test testTask : testTasks) { if (GradleVersion.current().compareTo(GradleVersion.version("4.0")) >= 0) { @@ -163,7 +168,7 @@ private DefaultGradleSourceSet getSourceSet(Project project, SourceSet sourceSet break; } } catch (NoSuchMethodException | SecurityException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException e) { + | IllegalArgumentException | InvocationTargetException e) { // ignore } } @@ -215,8 +220,7 @@ private Map> getArchiveOutputFiles(Project project, SourceSet s } else { archiveFile = archiveTask.getArchivePath(); } - List sourceSetOutputs = new LinkedList<>(); - sourceSetOutputs.addAll(sourceSet.getOutput().getFiles()); + List sourceSetOutputs = new LinkedList<>(sourceSet.getOutput().getFiles()); archiveOutputFiles.put(archiveFile, sourceSetOutputs); } } @@ -258,7 +262,7 @@ private void excludeSourceDirsFromModules(List sourceSets) { for (GradleSourceSet sourceSet : sourceSets) { Set filteredModuleDependencies = sourceSet.getModuleDependencies() .stream().filter(mod -> mod.getArtifacts() - .stream().anyMatch(art -> !exclusionUris.contains(art.getUri()))) + .stream().anyMatch(art -> !exclusionUris.contains(art.getUri()))) .collect(Collectors.toSet()); if (sourceSet instanceof DefaultGradleSourceSet) { ((DefaultGradleSourceSet) sourceSet).setModuleDependencies(filteredModuleDependencies); @@ -269,7 +273,7 @@ private void excludeSourceDirsFromModules(List sourceSets) { private Collection getSourceSetContainer(Project project) { if (GradleVersion.current().compareTo(GradleVersion.version("5.0")) >= 0) { SourceSetContainer sourceSetContainer = project.getExtensions() - .findByType(SourceSetContainer.class); + .findByType(SourceSetContainer.class); if (sourceSetContainer != null) { return sourceSetContainer; } @@ -289,7 +293,7 @@ private Collection getSourceSetContainer(Project project) { return (SourceSetContainer) getSourceSetsMethod.invoke(pluginConvention); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException e) { + | IllegalArgumentException | InvocationTargetException e) { // ignore } return new LinkedList<>(); @@ -342,7 +346,7 @@ private Set getArchiveSourcePaths(CopySpec copySpec) { } } } catch (NoSuchMethodException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException e) { + | IllegalArgumentException | InvocationTargetException e) { // cannot get archive information } } diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidVariant.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidVariant.java deleted file mode 100644 index aaea119c..00000000 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/model/AndroidVariant.java +++ /dev/null @@ -1,241 +0,0 @@ -package com.microsoft.java.bs.gradle.plugin.model; - -import com.microsoft.java.bs.gradle.model.BuildTargetDependency; -import com.microsoft.java.bs.gradle.model.GradleModuleDependency; -import com.microsoft.java.bs.gradle.model.LanguageExtension; - -import java.io.File; -import java.util.Map; -import java.util.Set; - -public class AndroidVariant { - - private String gradleVersion; - private String displayName; - private String projectName; - private String projectPath; - private File projectDir; - private File rootDir; - private String variantName; - private String classesTaskName; - private String cleanTaskName; - private Set taskNames; - private Set sourceDirs; - private Set generatedSourceDirs; - private File sourceOutputDir; - private Set resourceDirs; - private File resourceOutputDir; - private Set compileClasspath; - private Set moduleDependencies; - private Set buildTargetDependencies; - private boolean hasTests; - private Map extensions; - - public AndroidVariant() { - } - - public AndroidVariant( - String gradleVersion, - String displayName, - String projectName, - String projectPath, - File projectDir, - File rootDir, - String variantName, - String classesTaskName, - String cleanTaskName, - Set taskNames, - Set sourceDirs, - Set generatedSourceDirs, - File sourceOutputDir, - Set resourceDirs, - File resourceOutputDir, - Set compileClasspath, - Set moduleDependencies, - Set buildTargetDependencies, - boolean hasTests, - Map extensions - ) { - this.gradleVersion = gradleVersion; - this.displayName = displayName; - this.projectName = projectName; - this.projectPath = projectPath; - this.projectDir = projectDir; - this.rootDir = rootDir; - this.variantName = variantName; - this.classesTaskName = classesTaskName; - this.cleanTaskName = cleanTaskName; - this.taskNames = taskNames; - this.sourceDirs = sourceDirs; - this.generatedSourceDirs = generatedSourceDirs; - this.sourceOutputDir = sourceOutputDir; - this.resourceDirs = resourceDirs; - this.resourceOutputDir = resourceOutputDir; - this.compileClasspath = compileClasspath; - this.moduleDependencies = moduleDependencies; - this.buildTargetDependencies = buildTargetDependencies; - this.hasTests = hasTests; - this.extensions = extensions; - } - - public String getGradleVersion() { - return gradleVersion; - } - - public void setGradleVersion(String gradleVersion) { - this.gradleVersion = gradleVersion; - } - - public String getDisplayName() { - return displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public String getProjectName() { - return projectName; - } - - public void setProjectName(String projectName) { - this.projectName = projectName; - } - - public String getProjectPath() { - return projectPath; - } - - public void setProjectPath(String projectPath) { - this.projectPath = projectPath; - } - - public File getProjectDir() { - return projectDir; - } - - public void setProjectDir(File projectDir) { - this.projectDir = projectDir; - } - - public File getRootDir() { - return rootDir; - } - - public void setRootDir(File rootDir) { - this.rootDir = rootDir; - } - - public String getVariantName() { - return variantName; - } - - public void setVariantName(String variantName) { - this.variantName = variantName; - } - - public String getClassesTaskName() { - return classesTaskName; - } - - public void setClassesTaskName(String classesTaskName) { - this.classesTaskName = classesTaskName; - } - - public String getCleanTaskName() { - return cleanTaskName; - } - - public void setCleanTaskName(String cleanTaskName) { - this.cleanTaskName = cleanTaskName; - } - - public Set getTaskNames() { - return taskNames; - } - - public void setTaskNames(Set taskNames) { - this.taskNames = taskNames; - } - - public Set getSourceDirs() { - return sourceDirs; - } - - public void setSourceDirs(Set sourceDirs) { - this.sourceDirs = sourceDirs; - } - - public Set getGeneratedSourceDirs() { - return generatedSourceDirs; - } - - public void setGeneratedSourceDirs(Set generatedSourceDirs) { - this.generatedSourceDirs = generatedSourceDirs; - } - - public File getSourceOutputDir() { - return sourceOutputDir; - } - - public void setSourceOutputDir(File sourceOutputDir) { - this.sourceOutputDir = sourceOutputDir; - } - - public Set getResourceDirs() { - return resourceDirs; - } - - public void setResourceDirs(Set resourceDirs) { - this.resourceDirs = resourceDirs; - } - - public File getResourceOutputDir() { - return resourceOutputDir; - } - - public void setResourceOutputDir(File resourceOutputDir) { - this.resourceOutputDir = resourceOutputDir; - } - - public Set getCompileClasspath() { - return compileClasspath; - } - - public void setCompileClasspath(Set compileClasspath) { - this.compileClasspath = compileClasspath; - } - - public Set getModuleDependencies() { - return moduleDependencies; - } - - public void setModuleDependencies(Set moduleDependencies) { - this.moduleDependencies = moduleDependencies; - } - - public Set getBuildTargetDependencies() { - return buildTargetDependencies; - } - - public void setBuildTargetDependencies(Set buildTargetDependencies) { - this.buildTargetDependencies = buildTargetDependencies; - } - - public boolean isHasTests() { - return hasTests; - } - - public void setHasTests(boolean hasTests) { - this.hasTests = hasTests; - } - - public Map getExtensions() { - return extensions; - } - - public void setExtensions(Map extensions) { - this.extensions = extensions; - } - -} diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java similarity index 60% rename from plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java rename to plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java index dfe8c6d1..1cc790ff 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java @@ -1,6 +1,7 @@ package com.microsoft.java.bs.gradle.plugin.utils; -import com.microsoft.java.bs.gradle.plugin.model.AndroidVariant; +import com.microsoft.java.bs.gradle.model.GradleSourceSet; +import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSet; import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.provider.Provider; @@ -9,28 +10,28 @@ import java.lang.reflect.InvocationTargetException; import java.util.*; -public class SourceSetUtils { +public class AndroidUtils { - private SourceSetUtils() { + private AndroidUtils() { } public static boolean isAndroidProject(Project project) { - return getProjectExtension(project, "android") != null; + return getAndroidExtension(project) != null; } @SuppressWarnings("unchecked") - public static List getAndroidBuildVariants(Project project) { + public static List getBuildVariantsAsGradleSourceSets(Project project) { - List androidBuildVariants = new LinkedList<>(); + List sourceSets = new LinkedList<>(); - Object androidExtension = getProjectExtension(project, "android"); + Object androidExtension = getAndroidExtension(project); if (androidExtension == null) { - return androidBuildVariants; + return sourceSets; } AndroidProjectType type = getProjectType(project); if (type == null) { - return androidBuildVariants; + return sourceSets; } String methodName = ""; @@ -53,41 +54,54 @@ public static List getAndroidBuildVariants(Project project) { try { Set variants = (Set) androidExtension.getClass().getMethod(methodName).invoke(androidExtension); for (Object variant : variants) { - AndroidVariant androidVariant = convertToAndroidVariant(project, variant); - if (androidVariant == null) { + GradleSourceSet sourceSet = convertVariantToGradleSourceSet(project, variant); + if (sourceSet == null) { continue; } - androidBuildVariants.add(androidVariant); + sourceSets.add(sourceSet); } } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | ClassCastException e) { // do nothing } - return androidBuildVariants; + return sourceSets; } @SuppressWarnings("unchecked") - public static AndroidVariant convertToAndroidVariant(Project project, Object variant) { + private static GradleSourceSet convertVariantToGradleSourceSet(Project project, Object variant) { try { - AndroidVariant androidVariant = new AndroidVariant(); + DefaultGradleSourceSet gradleSourceSet = new DefaultGradleSourceSet(); + gradleSourceSet.setBuildTargetDependencies(new HashSet<>()); - androidVariant.setGradleVersion(project.getGradle().getGradleVersion()); - androidVariant.setProjectName(project.getName()); - androidVariant.setDisplayName(project.getDisplayName()); - androidVariant.setProjectPath(project.getPath()); - androidVariant.setProjectDir(project.getProjectDir()); - androidVariant.setRootDir(project.getRootDir()); + gradleSourceSet.setGradleVersion(project.getGradle().getGradleVersion()); + gradleSourceSet.setProjectName(project.getName()); + String projectPath = project.getPath(); + gradleSourceSet.setProjectPath(projectPath); + gradleSourceSet.setProjectDir(project.getProjectDir()); + gradleSourceSet.setRootDir(project.getRootDir()); String variantName = (String) variant.getClass().getMethod("getName").invoke(variant); - androidVariant.setVariantName(variantName); + gradleSourceSet.setSourceSetName(variantName); - // classpath - Object compileConfig = variant.getClass().getMethod("getCompileConfiguration").invoke(variant); - Set classpathFiles = (Set) compileConfig.getClass().getMethod("getFiles").invoke(compileConfig); - androidVariant.setCompileClasspath(classpathFiles); + // TODO: Get classes task equivalent in android build variant + + // TODO: Get clean task equivalent in android build variant + + // TODO: Set task names + + String projectName = stripPathPrefix(projectPath); + if (projectName.isEmpty()) { + projectName = project.getName(); + } + String displayName = projectName + " [" + variantName + ']'; + gradleSourceSet.setDisplayName(displayName); + + // TODO: Set Module dependencies + + // TODO: Extensions, SourceOutputDirs // source Object sourceSets = getProperty(variant, "sourceSets"); @@ -98,21 +112,28 @@ public static AndroidVariant convertToAndroidVariant(Project project, Object var sourceDirs.addAll(javaDirs); } } - androidVariant.setSourceDirs(sourceDirs); + gradleSourceSet.setSourceDirs(sourceDirs); - // generated source + // generated source TODO: Not complete Set generatedOutputs = new HashSet<>(); - Provider javaCompileTask = (Provider) getProperty(variant, "javaCompileProvider"); if (javaCompileTask != null) { generatedOutputs.addAll(javaCompileTask.get().getOutputs().getFiles().getFiles()); } + gradleSourceSet.setGeneratedSourceDirs(generatedOutputs); + + // classpath + Object compileConfig = variant.getClass().getMethod("getCompileConfiguration").invoke(variant); + Set classpathFiles = (Set) compileConfig.getClass().getMethod("getFiles").invoke(compileConfig); + gradleSourceSet.setCompileClasspath(new LinkedList<>(classpathFiles)); - androidVariant.setGeneratedSourceDirs(generatedOutputs); + // resource dirs TODO: Needed? - // source output + // TODO: Set Archive output dirs - return androidVariant; + // TODO: Set if has Tests + + return gradleSourceSet; } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { return null; @@ -120,14 +141,14 @@ public static AndroidVariant convertToAndroidVariant(Project project, Object var } - public static Object getProjectExtension(Project project, String extensionName) { + private static Object getAndroidExtension(Project project) { Object extension = null; try { Object convention = project.getClass().getMethod("getConvention").invoke(project); Object extensionMap = convention.getClass().getMethod("getAsMap").invoke(convention); - extension = extensionMap.getClass().getMethod("get", Object.class).invoke(extensionMap, extensionName); + extension = extensionMap.getClass().getMethod("get", Object.class).invoke(extensionMap, "android"); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { // do nothing } @@ -136,9 +157,9 @@ public static Object getProjectExtension(Project project, String extensionName) } - public static AndroidProjectType getProjectType(Project project) { + private static AndroidProjectType getProjectType(Project project) { - if (getProjectExtension(project, "android") == null) { + if (getAndroidExtension(project) == null) { return null; } @@ -165,7 +186,7 @@ private static Object getProperty(Object obj, String propertyName) return obj.getClass().getMethod("getProperty", String.class).invoke(obj, propertyName); } - public enum AndroidProjectType { + private enum AndroidProjectType { APPLICATION, LIBRARY, DYNAMIC_FEATURE, @@ -173,4 +194,11 @@ public enum AndroidProjectType { ANDROID_TEST } + private static String stripPathPrefix(String projectPath) { + if (projectPath.startsWith(":")) { + return projectPath.substring(1); + } + return projectPath; + } + } From b2bb34d1d1e06c506d5e7314f9c57352bbf05d36 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Sun, 18 Aug 2024 21:50:46 +0530 Subject: [PATCH 07/15] Refactored AndroidUtils to populate almost all the android build target properties. Changes: - Added most of the android build target properties. - Addressed checkstyle warnings - Changed GradleSourceSet to store set of resource output directories instead of one directory. - Removed temporary android testing methods. --- .../java/bs/gradle/model/GradleSourceSet.java | 4 +- .../model/actions/GetSourceSetsAction.java | 18 +- .../model/impl/DefaultGradleSourceSet.java | 16 +- .../gradle/plugin/SourceSetsModelBuilder.java | 9 +- .../AndroidDependencyCollector.java | 217 ++++++++++++++++++ .../bs/gradle/plugin/utils/AndroidUtils.java | 175 +++++++++++--- .../plugin/GradleBuildServerPluginTest.java | 6 +- .../internal/services/BuildTargetService.java | 82 +++---- .../services/BuildTargetServiceTest.java | 4 +- testProjects/android-test/build.gradle | 2 +- 10 files changed, 425 insertions(+), 108 deletions(-) create mode 100644 plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java diff --git a/model/src/main/java/com/microsoft/java/bs/gradle/model/GradleSourceSet.java b/model/src/main/java/com/microsoft/java/bs/gradle/model/GradleSourceSet.java index 465b2783..cf5f57e6 100644 --- a/model/src/main/java/com/microsoft/java/bs/gradle/model/GradleSourceSet.java +++ b/model/src/main/java/com/microsoft/java/bs/gradle/model/GradleSourceSet.java @@ -86,9 +86,9 @@ public interface GradleSourceSet extends Serializable { Set getSourceOutputDirs(); /** - * The resource output directory of this source set. + * The resource output directories of this source set. */ - public File getResourceOutputDir(); + public Set getResourceOutputDirs(); /** * Any archive files created from the output of this source set to the output dirs. diff --git a/model/src/main/java/com/microsoft/java/bs/gradle/model/actions/GetSourceSetsAction.java b/model/src/main/java/com/microsoft/java/bs/gradle/model/actions/GetSourceSetsAction.java index e655ef09..852a876b 100644 --- a/model/src/main/java/com/microsoft/java/bs/gradle/model/actions/GetSourceSetsAction.java +++ b/model/src/main/java/com/microsoft/java/bs/gradle/model/actions/GetSourceSetsAction.java @@ -46,12 +46,12 @@ private Collection fetchIncludedBuilds(BuildController buildControl Map builds = new HashMap<>(); GradleBuild build = buildController.getBuildModel(); String rootProjectName = build.getRootProject().getName(); - fetchIncludedBuilds(buildController, build, builds, rootProjectName); + fetchIncludedBuilds(build, builds, rootProjectName); return builds.values(); } - private void fetchIncludedBuilds(BuildController buildController, GradleBuild build, - Map builds, String rootProjectName) { + private void fetchIncludedBuilds(GradleBuild build, Map builds, String rootProjectName) { if (builds.containsKey(rootProjectName)) { return; } @@ -75,7 +75,7 @@ private void fetchIncludedBuilds(BuildController buildController, GradleBuild bu if (moreBuilds != null) { for (GradleBuild includedBuild : moreBuilds) { String includedBuildName = includedBuild.getRootProject().getName(); - fetchIncludedBuilds(buildController, includedBuild, builds, includedBuildName); + fetchIncludedBuilds(includedBuild, builds, includedBuildName); } } } @@ -87,7 +87,7 @@ private void fetchIncludedBuilds(BuildController buildController, GradleBuild bu * @param builds The Gradle build models representing the build and included builds. */ private List fetchModels(BuildController buildController, - Collection builds) { + Collection builds) { List projectActions = new ArrayList<>(); for (GradleBuild build : builds) { @@ -101,7 +101,7 @@ private List fetchModels(BuildController buildController, // populate source set dependencies. List sourceSets = buildController.run(projectActions).stream() .flatMap(ss -> ss.getGradleSourceSets().stream()) - .map(ss -> new DefaultGradleSourceSet(ss)) + .map(DefaultGradleSourceSet::new) .collect(Collectors.toList()); populateInterProjectInfo(sourceSets); @@ -140,8 +140,10 @@ private void populateInterProjectInfo(List sourceSets) { outputsToSourceSet.put(file, sourceSet); } } - if (sourceSet.getResourceOutputDir() != null) { - outputsToSourceSet.put(sourceSet.getResourceOutputDir(), sourceSet); + if (sourceSet.getResourceOutputDirs() != null) { + for (File file : sourceSet.getResourceOutputDirs()) { + outputsToSourceSet.put(file, sourceSet); + } } if (sourceSet.getArchiveOutputFiles() != null) { for (Map.Entry> archive : sourceSet.getArchiveOutputFiles().entrySet()) { diff --git a/model/src/main/java/com/microsoft/java/bs/gradle/model/impl/DefaultGradleSourceSet.java b/model/src/main/java/com/microsoft/java/bs/gradle/model/impl/DefaultGradleSourceSet.java index 97151aae..45ffb04f 100644 --- a/model/src/main/java/com/microsoft/java/bs/gradle/model/impl/DefaultGradleSourceSet.java +++ b/model/src/main/java/com/microsoft/java/bs/gradle/model/impl/DefaultGradleSourceSet.java @@ -49,7 +49,7 @@ public class DefaultGradleSourceSet implements GradleSourceSet { private Set resourceDirs; - private File resourceOutputDir; + private Set resourceOutputDirs; private Map> archiveOutputFiles; @@ -85,7 +85,7 @@ public DefaultGradleSourceSet(GradleSourceSet gradleSourceSet) { this.generatedSourceDirs = gradleSourceSet.getGeneratedSourceDirs(); this.sourceOutputDirs = gradleSourceSet.getSourceOutputDirs(); this.resourceDirs = gradleSourceSet.getResourceDirs(); - this.resourceOutputDir = gradleSourceSet.getResourceOutputDir(); + this.resourceOutputDirs = gradleSourceSet.getResourceOutputDirs(); this.archiveOutputFiles = gradleSourceSet.getArchiveOutputFiles(); this.compileClasspath = gradleSourceSet.getCompileClasspath(); this.moduleDependencies = gradleSourceSet.getModuleDependencies().stream() @@ -234,12 +234,12 @@ public void setResourceDirs(Set resourceDirs) { } @Override - public File getResourceOutputDir() { - return resourceOutputDir; + public Set getResourceOutputDirs() { + return resourceOutputDirs; } - public void setResourceOutputDir(File resourceOutputDir) { - this.resourceOutputDir = resourceOutputDir; + public void setResourceOutputDirs(Set resourceOutputDirs) { + this.resourceOutputDirs = resourceOutputDirs; } @Override @@ -300,7 +300,7 @@ public void setExtensions(Map extensions) { public int hashCode() { return Objects.hash(gradleVersion, displayName, projectName, projectPath, projectDir, rootDir, sourceSetName, classesTaskName, cleanTaskName, taskNames, sourceDirs, - generatedSourceDirs, sourceOutputDirs, resourceDirs, resourceOutputDir, archiveOutputFiles, + generatedSourceDirs, sourceOutputDirs, resourceDirs, resourceOutputDirs, archiveOutputFiles, compileClasspath, moduleDependencies, buildTargetDependencies, hasTests, extensions); } @@ -331,7 +331,7 @@ public boolean equals(Object obj) { && Objects.equals(generatedSourceDirs, other.generatedSourceDirs) && Objects.equals(sourceOutputDirs, other.sourceOutputDirs) && Objects.equals(resourceDirs, other.resourceDirs) - && Objects.equals(resourceOutputDir, other.resourceOutputDir) + && Objects.equals(resourceOutputDirs, other.resourceOutputDirs) && Objects.equals(archiveOutputFiles, other.archiveOutputFiles) && Objects.equals(compileClasspath, other.compileClasspath) && Objects.equals(moduleDependencies, other.moduleDependencies) diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java index 9474cd70..793fc295 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java @@ -53,6 +53,7 @@ public Object buildAll(String modelName, Project project) { // mapping Gradle source set to our customized model. List sourceSets; + // Fetch source sets depending on the project type if (AndroidUtils.isAndroidProject(project)) { sourceSets = AndroidUtils.getBuildVariantsAsGradleSourceSets(project); } else { @@ -131,9 +132,11 @@ private DefaultGradleSourceSet getSourceSet(Project project, SourceSet sourceSet // resource output dir File resourceOutputDir = sourceSet.getOutput().getResourcesDir(); + Set resourceOutputDirs = new HashSet<>(); if (resourceOutputDir != null) { - gradleSourceSet.setResourceOutputDir(resourceOutputDir); + resourceOutputDirs.add(resourceOutputDir); } + gradleSourceSet.setResourceOutputDirs(resourceOutputDirs); // archive output dirs Map> archiveOutputFiles = getArchiveOutputFiles(project, sourceSet); @@ -249,8 +252,8 @@ private void excludeSourceDirsFromModules(List sourceSets) { if (sourceSet.getSourceOutputDirs() != null) { exclusions.addAll(sourceSet.getSourceOutputDirs()); } - if (sourceSet.getResourceOutputDir() != null) { - exclusions.add(sourceSet.getResourceOutputDir()); + if (sourceSet.getResourceOutputDirs() != null) { + exclusions.addAll(sourceSet.getResourceOutputDirs()); } if (sourceSet.getArchiveOutputFiles() != null) { exclusions.addAll(sourceSet.getArchiveOutputFiles().keySet()); diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java new file mode 100644 index 00000000..42550014 --- /dev/null +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java @@ -0,0 +1,217 @@ +package com.microsoft.java.bs.gradle.plugin.dependency; + +import com.microsoft.java.bs.gradle.model.Artifact; +import com.microsoft.java.bs.gradle.model.GradleModuleDependency; +import com.microsoft.java.bs.gradle.model.impl.DefaultArtifact; +import com.microsoft.java.bs.gradle.model.impl.DefaultGradleModuleDependency; +import com.microsoft.java.bs.gradle.plugin.utils.AndroidUtils; +import org.gradle.api.Project; +import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.component.ComponentArtifactIdentifier; +import org.gradle.api.artifacts.result.ArtifactResolutionResult; +import org.gradle.api.artifacts.result.ArtifactResult; +import org.gradle.api.artifacts.result.ComponentArtifactsResult; +import org.gradle.api.artifacts.result.ResolvedArtifactResult; +import org.gradle.api.component.Component; +import org.gradle.api.specs.Specs; +import org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier; +import org.gradle.internal.component.local.model.ComponentFileArtifactIdentifier; +import org.gradle.internal.component.local.model.OpaqueComponentArtifactIdentifier; +import org.gradle.language.base.artifact.SourcesArtifact; +import org.gradle.language.java.artifact.JavadocArtifact; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * TODO: JavaDoc. + */ +public class AndroidDependencyCollector { + + private static final String UNKNOWN = "unknown"; + + /** + * Resolve and collect dependencies from an Android variant. + */ + public static Set getModuleDependencies(Project project, Object variant) { + Set dependencies = new HashSet<>(); + ClassLoader agpClassLoader = variant.getClass().getClassLoader(); + + try { + // Retrieve and process compile configuration + Configuration compileConfiguration = + (Configuration) AndroidUtils.getProperty(variant, "compileConfiguration"); + dependencies.addAll(resolveConfigurationDependencies( + project, + compileConfiguration, + agpClassLoader) + ); + + // Retrieve and process runtime configuration + Configuration runtimeConfiguration = + (Configuration) AndroidUtils.getProperty(variant, "runtimeConfiguration"); + dependencies.addAll(resolveConfigurationDependencies( + project, + runtimeConfiguration, + agpClassLoader) + ); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + + return dependencies; + } + + /** + * Resolve and collect dependencies from a given configuration. + */ + private static Set resolveConfigurationDependencies( + Project project, + Configuration configuration, + ClassLoader agpClassLoader + ) { + return configuration.getIncoming() + .artifactView(viewConfiguration -> { + viewConfiguration.lenient(true); + viewConfiguration.componentFilter(Specs.satisfyAll()); + }) + .getArtifacts() + .getArtifacts() + .stream() + .map(artifactResult -> getArtifact(project, artifactResult, agpClassLoader)) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + } + + private static DefaultGradleModuleDependency getArtifact( + Project project, + ResolvedArtifactResult artifactResult, + ClassLoader agpClassLoader + ) { + ComponentArtifactIdentifier id = artifactResult.getId(); + File artifactFile = artifactResult.getFile(); + if (id instanceof ModuleComponentArtifactIdentifier) { + return getModuleArtifactDependency( + project, + (ModuleComponentArtifactIdentifier) id, + artifactFile, + agpClassLoader + ); + } + if (id instanceof OpaqueComponentArtifactIdentifier) { + return getFileArtifactDependency((OpaqueComponentArtifactIdentifier) id, artifactFile); + } + if (id instanceof ComponentFileArtifactIdentifier) { + return getFileArtifactDependency((ComponentFileArtifactIdentifier) id, artifactFile); + } + return null; + } + + @SuppressWarnings("unchecked") + private static DefaultGradleModuleDependency getModuleArtifactDependency( + Project project, + ModuleComponentArtifactIdentifier artifactIdentifier, + File resolvedArtifactFile, + ClassLoader agpClassLoader + ) { + + try { + Class androidLibClazz = + (Class) agpClassLoader + .loadClass("com.android.build.api.variant.LibraryVariant"); + + ArtifactResolutionResult resolutionResult = project.getDependencies() + .createArtifactResolutionQuery() + .forComponents(artifactIdentifier.getComponentIdentifier()) + .withArtifacts( + androidLibClazz /* componentType */, + JavadocArtifact.class, SourcesArtifact.class /*artifactTypes*/ + ) + .execute(); + + List artifacts = new LinkedList<>(); + if (resolvedArtifactFile != null) { + artifacts.add(new DefaultArtifact(resolvedArtifactFile.toURI(), null)); + } + + Set resolvedComponents = resolutionResult.getResolvedComponents(); + File sourceJar = getNonClassesArtifact(resolvedComponents, SourcesArtifact.class); + if (sourceJar != null) { + artifacts.add(new DefaultArtifact(sourceJar.toURI(), "sources")); + } + + File javaDocJar = getNonClassesArtifact(resolvedComponents, JavadocArtifact.class); + if (javaDocJar != null) { + artifacts.add(new DefaultArtifact(javaDocJar.toURI(), "javadoc")); + } + + return new DefaultGradleModuleDependency( + artifactIdentifier.getComponentIdentifier().getGroup(), + artifactIdentifier.getComponentIdentifier().getModule(), + artifactIdentifier.getComponentIdentifier().getVersion(), + artifacts + ); + } catch (ClassNotFoundException e) { + return null; + } + + } + + private static File getNonClassesArtifact( + Set resolvedComponents, + Class artifactClass + ) { + for (ComponentArtifactsResult component : resolvedComponents) { + Set artifacts = component.getArtifacts(artifactClass); + for (ArtifactResult artifact : artifacts) { + if (artifact instanceof ResolvedArtifactResult) { + return ((ResolvedArtifactResult) artifact).getFile(); + } + } + } + return null; + } + + private static DefaultGradleModuleDependency getFileArtifactDependency( + ComponentFileArtifactIdentifier artifactIdentifier, + File resolvedArtifactFile + ) { + return getFileArtifactDependency( + artifactIdentifier.getCapitalizedDisplayName(), + resolvedArtifactFile + ); + } + + private static DefaultGradleModuleDependency getFileArtifactDependency( + OpaqueComponentArtifactIdentifier artifactIdentifier, + File resolvedArtifactFile + ) { + return getFileArtifactDependency( + artifactIdentifier.getCapitalizedDisplayName(), + resolvedArtifactFile + ); + } + + private static DefaultGradleModuleDependency getFileArtifactDependency( + String displayName, + File resolvedArtifactFile + ) { + List artifacts = new LinkedList<>(); + if (resolvedArtifactFile != null) { + artifacts.add(new DefaultArtifact(resolvedArtifactFile.toURI(), null)); + } + + return new DefaultGradleModuleDependency( + UNKNOWN, + displayName, + UNKNOWN, + artifacts + ); + } +} diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java index 1cc790ff..6a594ee9 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java @@ -1,24 +1,40 @@ package com.microsoft.java.bs.gradle.plugin.utils; +import com.microsoft.java.bs.gradle.model.GradleModuleDependency; import com.microsoft.java.bs.gradle.model.GradleSourceSet; import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSet; +import com.microsoft.java.bs.gradle.plugin.dependency.AndroidDependencyCollector; import org.gradle.api.Project; import org.gradle.api.Task; +import org.gradle.api.file.RegularFile; import org.gradle.api.provider.Provider; import java.io.File; import java.lang.reflect.InvocationTargetException; -import java.util.*; - +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.LinkedList; +import java.util.Set; + +/** + * TODO: JavaDoc. + */ public class AndroidUtils { private AndroidUtils() { } + /** + * TODO: JavaDoc. + */ public static boolean isAndroidProject(Project project) { return getAndroidExtension(project) != null; } + /** + * TODO: JavaDoc. + */ @SuppressWarnings("unchecked") public static List getBuildVariantsAsGradleSourceSets(Project project) { @@ -34,7 +50,7 @@ public static List getBuildVariantsAsGradleSourceSets(Project p return sourceSets; } - String methodName = ""; + String methodName; switch (type) { case APPLICATION: case DYNAMIC_FEATURE: @@ -49,10 +65,13 @@ public static List getBuildVariantsAsGradleSourceSets(Project p case ANDROID_TEST: methodName = "getTestVariants"; break; + default: + methodName = ""; } try { - Set variants = (Set) androidExtension.getClass().getMethod(methodName).invoke(androidExtension); + Set variants = + (Set) androidExtension.getClass().getMethod(methodName).invoke(androidExtension); for (Object variant : variants) { GradleSourceSet sourceSet = convertVariantToGradleSourceSet(project, variant); if (sourceSet == null) { @@ -60,7 +79,8 @@ public static List getBuildVariantsAsGradleSourceSets(Project p } sourceSets.add(sourceSet); } - } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | ClassCastException e) { + } catch (IllegalAccessException | NoSuchMethodException + | InvocationTargetException | ClassCastException e) { // do nothing } @@ -86,11 +106,17 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, String variantName = (String) variant.getClass().getMethod("getName").invoke(variant); gradleSourceSet.setSourceSetName(variantName); - // TODO: Get classes task equivalent in android build variant + // classes task equivalent in android (assembleRelease) + gradleSourceSet.setClassesTaskName( + getFullTaskName(projectPath, "assemble" + capitalize(variantName)) + ); - // TODO: Get clean task equivalent in android build variant + gradleSourceSet.setCleanTaskName(getFullTaskName(projectPath, "clean")); - // TODO: Set task names + // compile task in android (compileReleaseJavaWithJavac) + HashSet tasks = new HashSet<>(); + tasks.add("compile" + capitalize(variantName) + "JavaWithJavac"); + gradleSourceSet.setTaskNames(tasks); String projectName = stripPathPrefix(projectPath); if (projectName.isEmpty()) { @@ -100,38 +126,112 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, gradleSourceSet.setDisplayName(displayName); // TODO: Set Module dependencies + Set moduleDependencies = + AndroidDependencyCollector.getModuleDependencies(project, variant); + gradleSourceSet.setModuleDependencies(moduleDependencies); - // TODO: Extensions, SourceOutputDirs + // extensions + gradleSourceSet.setExtensions(new HashMap<>()); - // source + // source and resource Object sourceSets = getProperty(variant, "sourceSets"); Set sourceDirs = new HashSet<>(); + Set resourceDirs = new HashSet<>(); if (sourceSets instanceof Iterable) { for (Object sourceSet : (Iterable) sourceSets) { - Set javaDirs = (Set) getProperty(sourceSet, "javaDirectories"); - sourceDirs.addAll(javaDirs); + Set javaDirectories = + (Set) getProperty(sourceSet, "javaDirectories"); + Set resDirectories = + (Set) getProperty(sourceSet, "resDirectories"); + Set resourceDirectories = + (Set) getProperty(sourceSet, "resourcesDirectories"); + sourceDirs.addAll(javaDirectories); + resourceDirs.addAll(resDirectories); + resourceDirs.addAll(resourceDirectories); } } gradleSourceSet.setSourceDirs(sourceDirs); - - // generated source TODO: Not complete - Set generatedOutputs = new HashSet<>(); - Provider javaCompileTask = (Provider) getProperty(variant, "javaCompileProvider"); - if (javaCompileTask != null) { - generatedOutputs.addAll(javaCompileTask.get().getOutputs().getFiles().getFiles()); + gradleSourceSet.setResourceDirs(resourceDirs); + + // resource outputs + Set resourceOutputs = new HashSet<>(); + Provider resourceProvider = + (Provider) getProperty(variant, "processJavaResourcesProvider"); + if (resourceProvider != null) { + Task resTask = resourceProvider.get(); + File outputDir = + (File) resTask.getClass().getMethod("getDestinationDir").invoke(resTask); + resourceOutputs.add(outputDir); + } + Provider resProvider = + (Provider) getProperty(variant, "mergeResourcesProvider"); + if (resProvider != null) { + Task resTask = resProvider.get(); + Object outputDir = + resTask.getClass().getMethod("getOutputDir").invoke(resTask); + File output = + ((Provider) outputDir.getClass().getMethod("getAsFile").invoke(outputDir)).get(); + resourceOutputs.add(output); + } + gradleSourceSet.setResourceOutputDirs(resourceOutputs); + + // generated sources and source outputs + Set generatedSources = new HashSet<>(); + Set sourceOutputs = new HashSet<>(); + Provider javaCompileProvider = + (Provider) getProperty(variant, "javaCompileProvider"); + if (javaCompileProvider != null) { + Task javaCompileTask = javaCompileProvider.get(); + + File outputDir = (File) javaCompileTask.getClass().getMethod("getDestinationDir") + .invoke(javaCompileTask); + sourceOutputs.add(outputDir); + + Object source = javaCompileTask.getClass().getMethod("getSource").invoke(javaCompileTask); + Set compileSources = + (Set) source.getClass().getMethod("getFiles").invoke(source); + + // generated = compile source - source + for (File compileSource : compileSources) { + boolean inSourceDir = sourceDirs.stream() + .anyMatch(dir -> compileSource.getAbsolutePath().startsWith(dir.getAbsolutePath())); + if (inSourceDir) { + continue; + } + boolean inGeneratedSourceDir = generatedSources.stream() + .anyMatch(dir -> compileSource.getAbsolutePath().startsWith(dir.getAbsolutePath())); + if (inGeneratedSourceDir) { + continue; + } + generatedSources.add(compileSource); + } } - gradleSourceSet.setGeneratedSourceDirs(generatedOutputs); + gradleSourceSet.setGeneratedSourceDirs(generatedSources); + gradleSourceSet.setSourceOutputDirs(sourceOutputs); // classpath - Object compileConfig = variant.getClass().getMethod("getCompileConfiguration").invoke(variant); - Set classpathFiles = (Set) compileConfig.getClass().getMethod("getFiles").invoke(compileConfig); + Object compileConfig = variant.getClass() + .getMethod("getCompileConfiguration").invoke(variant); + Set classpathFiles = (Set) compileConfig.getClass() + .getMethod("getFiles").invoke(compileConfig); + // add R.jar file + String taskName = "process" + capitalize(variantName) + "Resources"; + Task processResourcesTask = project.getTasks().findByName(taskName); + if (processResourcesTask != null) { + Object output = processResourcesTask.getClass() + .getMethod("getRClassOutputJar").invoke(processResourcesTask); + RegularFile file = (RegularFile) output.getClass() + .getMethod("get").invoke(output); + classpathFiles.add(file.getAsFile()); + } gradleSourceSet.setCompileClasspath(new LinkedList<>(classpathFiles)); - // resource dirs TODO: Needed? - // TODO: Set Archive output dirs - // TODO: Set if has Tests + // has tests + Object unitTestVariant = variant.getClass().getMethod("getUnitTestVariant").invoke(variant); + Object testVariant = variant.getClass().getMethod("getTestVariant").invoke(variant); + gradleSourceSet.setHasTests(unitTestVariant != null || testVariant != null); return gradleSourceSet; @@ -148,7 +248,8 @@ private static Object getAndroidExtension(Project project) { try { Object convention = project.getClass().getMethod("getConvention").invoke(project); Object extensionMap = convention.getClass().getMethod("getAsMap").invoke(convention); - extension = extensionMap.getClass().getMethod("get", Object.class).invoke(extensionMap, "android"); + extension = extensionMap.getClass() + .getMethod("get", Object.class).invoke(extensionMap, "android"); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { // do nothing } @@ -181,7 +282,7 @@ private static AndroidProjectType getProjectType(Project project) { } - private static Object getProperty(Object obj, String propertyName) + public static Object getProperty(Object obj, String propertyName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { return obj.getClass().getMethod("getProperty", String.class).invoke(obj, propertyName); } @@ -201,4 +302,26 @@ private static String stripPathPrefix(String projectPath) { return projectPath; } + /** + * Return a project task name - [project path]:[task]. + */ + private static String getFullTaskName(String modulePath, String taskName) { + if (taskName == null) { + return null; + } + if (taskName.isEmpty()) { + return taskName; + } + + if (modulePath == null || modulePath.equals(":")) { + // must be prefixed with ":" as taskPaths are reported back like that in progress messages + return ":" + taskName; + } + return modulePath + ":" + taskName; + } + + private static String capitalize(String s) { + return s.substring(0, 1).toUpperCase() + s.substring(1); + } + } diff --git a/plugin/src/test/java/com/microsoft/java/bs/gradle/plugin/GradleBuildServerPluginTest.java b/plugin/src/test/java/com/microsoft/java/bs/gradle/plugin/GradleBuildServerPluginTest.java index 7c75c4ce..51ebb2f7 100644 --- a/plugin/src/test/java/com/microsoft/java/bs/gradle/plugin/GradleBuildServerPluginTest.java +++ b/plugin/src/test/java/com/microsoft/java/bs/gradle/plugin/GradleBuildServerPluginTest.java @@ -185,7 +185,7 @@ void testModelBuilder(GradleVersion gradleVersion) throws IOException { } assertEquals(1, gradleSourceSet.getResourceDirs().size()); assertNotNull(gradleSourceSet.getSourceOutputDirs()); - assertNotNull(gradleSourceSet.getResourceOutputDir()); + assertNotNull(gradleSourceSet.getResourceOutputDirs()); assertNotNull(gradleSourceSet.getBuildTargetDependencies()); assertNotNull(gradleSourceSet.getModuleDependencies()); @@ -486,7 +486,7 @@ void testScala2ModelBuilder(GradleVersion gradleVersion) throws IOException { assertNotNull(gradleSourceSet.getBuildTargetDependencies()); assertNotNull(gradleSourceSet.getModuleDependencies()); assertNotNull(gradleSourceSet.getSourceOutputDirs()); - assertNotNull(gradleSourceSet.getResourceOutputDir()); + assertNotNull(gradleSourceSet.getResourceOutputDirs()); JavaExtension javaExtension = SupportedLanguages.JAVA.getExtension(gradleSourceSet); assertNotNull(javaExtension); @@ -573,7 +573,7 @@ void testScala3ModelBuilder(GradleVersion gradleVersion) throws IOException { } assertEquals(1, gradleSourceSet.getResourceDirs().size()); assertNotNull(gradleSourceSet.getSourceOutputDirs()); - assertNotNull(gradleSourceSet.getResourceOutputDir()); + assertNotNull(gradleSourceSet.getResourceOutputDirs()); assertNotNull(gradleSourceSet.getBuildTargetDependencies()); assertNotNull(gradleSourceSet.getModuleDependencies()); JavaExtension javaExtension = SupportedLanguages.JAVA.getExtension(gradleSourceSet); diff --git a/server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java b/server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java index 70143c1e..095c573f 100644 --- a/server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java +++ b/server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java @@ -247,18 +247,20 @@ public OutputPathsResult getBuildTargetOutputPaths(OutputPathsParams params) { if (sourceOutputDirs != null) { for (File sourceOutputDir : sourceOutputDirs) { outputPaths.add(new OutputPathItem( - sourceOutputDir.toURI().toString() + "?kind=source", + sourceOutputDir.toURI() + "?kind=source", OutputPathItemKind.DIRECTORY )); } } - File resourceOutputDir = sourceSet.getResourceOutputDir(); - if (resourceOutputDir != null) { - outputPaths.add(new OutputPathItem( - resourceOutputDir.toURI().toString() + "?kind=resource", - OutputPathItemKind.DIRECTORY - )); + Set resourceOutputDirs = sourceSet.getResourceOutputDirs(); + if (resourceOutputDirs != null) { + for (File resourceOutputDir : resourceOutputDirs) { + outputPaths.add(new OutputPathItem( + resourceOutputDir.toURI() + "?kind=resource", + OutputPathItemKind.DIRECTORY + )); + } } OutputPathsItem item = new OutputPathsItem(btId, outputPaths); @@ -286,7 +288,7 @@ public DependencySourcesResult getBuildTargetDependencySources(DependencySources List artifacts = dep.getArtifacts().stream() .filter(a -> "sources".equals(a.getClassifier())) .map(a -> a.getUri().toString()) - .collect(Collectors.toList()); + .toList(); sources.addAll(artifacts); } @@ -488,19 +490,15 @@ public TestResult buildTargetTest(TestParams params) { TestResult testResult = new TestResult(StatusCode.OK); testResult.setOriginId(params.getOriginId()); // running tests can trigger compilation that must be reported on - CompileProgressReporter compileProgressReporter = new CompileProgressReporter(client, params.getOriginId(), getFullTaskPathMap()); - Map> groupedTargets = groupBuildTargetsByRootDir(params.getTargets()); + CompileProgressReporter compileProgressReporter = + new CompileProgressReporter(client, params.getOriginId(), getFullTaskPathMap()); + Map> groupedTargets = + groupBuildTargetsByRootDir(params.getTargets()); for (Map.Entry> entry : groupedTargets.entrySet()) { // TODO ideally BSP would have a jvmTestEnv style testkind for executing tests, not scala. StatusCode statusCode; - - // check if targets are android - boolean isAndroid = checkIfAndroidProject(entry.getValue()); - - if (isAndroid) { - statusCode = runAndroidTests(entry, params, compileProgressReporter); - } else if (TestParamsDataKind.SCALA_TEST.equals(params.getDataKind())) { + if (TestParamsDataKind.SCALA_TEST.equals(params.getDataKind())) { // existing logic for scala test (class level) statusCode = runScalaTests(entry, params, compileProgressReporter); } else if ("scala-test-suites-selection".equals(params.getDataKind())) { @@ -518,43 +516,11 @@ public TestResult buildTargetTest(TestParams params) { return testResult; } - private boolean checkIfAndroidProject(Set targets) { - // Logic to determine if the given targets are part of an Android Project - // This might involve checking the project type, build configuration, or specific Android build targets. - return targets.stream().anyMatch(this::isAndroidProject); - } - - private boolean isAndroidProject(BuildTargetIdentifier target) { - // TODO: Have GradleBuildTarget or the source set store type of project - java, scala, android, etc. - return false; - } - - private StatusCode runAndroidTests(Map.Entry> entry, TestParams params, CompileProgressReporter compileProgressReporter) { - // Logic to run tests: - // - Determine if unit tests or instrumentation tests are to be run. - // - If instrumentation tests, ensure an emulator/device is available and handle APK installation and execution. - // - Execute the tests and capture results. - - if (isUnitTest(entry)) { - // Run Android unit tests (similar to JVM tests) - return runScalaTests(entry, params, compileProgressReporter); - } else { - // Run instrumentation tests - return runInstrumentationTests(entry, params, compileProgressReporter); - } - } - - private boolean isUnitTest(Map.Entry> entry) { - // TODO: Check if the android test is a JVM unit test - return false; - } - - private StatusCode runInstrumentationTests(Map.Entry> targets, TestParams params, CompileProgressReporter compileProgressReporter) { - // Invoke AGP to run instrumentation test - return StatusCode.OK; - } - - private StatusCode runScalaTests(Map.Entry> entry, TestParams params, CompileProgressReporter compileProgressReporter) { + private StatusCode runScalaTests( + Map.Entry> entry, + TestParams params, + CompileProgressReporter compileProgressReporter + ) { // ScalaTestParams is for a list of classes only ScalaTestParams testParams = JsonUtils.toModel(params.getData(), ScalaTestParams.class); Map>> testClasses = new HashMap<>(); @@ -570,7 +536,11 @@ private StatusCode runScalaTests(Map.Entry> entr compileProgressReporter); } - private StatusCode runScalaTestSuitesSelection(Map.Entry> entry, TestParams params, CompileProgressReporter compileProgressReporter) { + private StatusCode runScalaTestSuitesSelection( + Map.Entry> entry, + TestParams params, + CompileProgressReporter compileProgressReporter + ) { // ScalaTestSuites is for a list of classes + methods // Since it doesn't supply the specific BuildTarget we require a single // build target in the params and reject any request that doesn't match this @@ -587,7 +557,7 @@ private StatusCode runScalaTestSuitesSelection(Map.Entry splitArgs = testSuites.getEnvironmentVariables() .stream() .map(arg -> arg.split("=")) - .collect(Collectors.toList()); + .toList(); argsValid = splitArgs.stream().allMatch(arg -> arg.length == 2); if (argsValid) { envVars = splitArgs.stream().collect(Collectors.toMap(arg -> arg[0], arg -> arg[1])); diff --git a/server/src/test/java/com/microsoft/java/bs/core/internal/services/BuildTargetServiceTest.java b/server/src/test/java/com/microsoft/java/bs/core/internal/services/BuildTargetServiceTest.java index dbf5a735..edded74e 100644 --- a/server/src/test/java/com/microsoft/java/bs/core/internal/services/BuildTargetServiceTest.java +++ b/server/src/test/java/com/microsoft/java/bs/core/internal/services/BuildTargetServiceTest.java @@ -190,7 +190,9 @@ void testGetBuildTargetOutputPaths() { sourceOutputDirs.add(sourceOutputDir); when(gradleSourceSet.getSourceOutputDirs()).thenReturn(sourceOutputDirs); File resourceOutputDir = new File(("resourceOutputDir")); - when(gradleSourceSet.getResourceOutputDir()).thenReturn(resourceOutputDir); + Set resourceOutputDirs = new HashSet<>(); + resourceOutputDirs.add(resourceOutputDir); + when(gradleSourceSet.getResourceOutputDirs()).thenReturn(resourceOutputDirs); BuildTargetService buildTargetService = new BuildTargetService(buildTargetManager, connector, preferenceManager); diff --git a/testProjects/android-test/build.gradle b/testProjects/android-test/build.gradle index 99e73ad4..41b070ae 100644 --- a/testProjects/android-test/build.gradle +++ b/testProjects/android-test/build.gradle @@ -1,5 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { -alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false } \ No newline at end of file From 43a47046b09ec1b2302bdbae311e67df32c15573 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Tue, 20 Aug 2024 08:36:18 +0530 Subject: [PATCH 08/15] JavaDocs and Refactoring between AndroidUtils and SourceSetsModelBuilder Changes: - Added JavaDocs to AndroidUtils - Added SourceSetUtils for common utility methods for SourceSets. - Removed common method declarations from AndroidUtils and SourceSetsModelBuilder into SourceSetUtils. --- .../gradle/plugin/SourceSetsModelBuilder.java | 39 +++------- .../AndroidDependencyCollector.java | 2 + .../bs/gradle/plugin/utils/AndroidUtils.java | 76 +++++++++++-------- .../gradle/plugin/utils/SourceSetUtils.java | 44 +++++++++++ 4 files changed, 100 insertions(+), 61 deletions(-) create mode 100644 plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java index 793fc295..96451398 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java @@ -17,6 +17,7 @@ import java.util.stream.Collectors; import com.microsoft.java.bs.gradle.plugin.utils.AndroidUtils; +import com.microsoft.java.bs.gradle.plugin.utils.SourceSetUtils; import org.gradle.api.GradleException; import org.gradle.api.Project; import org.gradle.api.Task; @@ -38,6 +39,7 @@ import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSet; import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSets; import com.microsoft.java.bs.gradle.plugin.dependency.DependencyCollector; +import org.jetbrains.annotations.NotNull; /** * The model builder for Gradle source sets. @@ -49,7 +51,7 @@ public boolean canBuild(String modelName) { } @Override - public Object buildAll(String modelName, Project project) { + public @NotNull Object buildAll(@NotNull String modelName, @NotNull Project project) { // mapping Gradle source set to our customized model. List sourceSets; @@ -77,13 +79,14 @@ private DefaultGradleSourceSet getSourceSet(Project project, SourceSet sourceSet gradleSourceSet.setProjectDir(project.getProjectDir()); gradleSourceSet.setRootDir(project.getRootDir()); gradleSourceSet.setSourceSetName(sourceSet.getName()); - String classesTaskName = getFullTaskName(projectPath, sourceSet.getClassesTaskName()); + String classesTaskName = + SourceSetUtils.getFullTaskName(projectPath, sourceSet.getClassesTaskName()); gradleSourceSet.setClassesTaskName(classesTaskName); - String cleanTaskName = getFullTaskName(projectPath, "clean"); + String cleanTaskName = SourceSetUtils.getFullTaskName(projectPath, "clean"); gradleSourceSet.setCleanTaskName(cleanTaskName); Set taskNames = new HashSet<>(); gradleSourceSet.setTaskNames(taskNames); - String projectName = stripPathPrefix(projectPath); + String projectName = SourceSetUtils.stripPathPrefix(projectPath); if (projectName.isEmpty()) { projectName = project.getName(); } @@ -102,7 +105,8 @@ private DefaultGradleSourceSet getSourceSet(Project project, SourceSet sourceSet LanguageExtension extension = languageModelBuilder.getExtensionFor(project, sourceSet, gradleSourceSet.getModuleDependencies()); if (extension != null) { - String compileTaskName = getFullTaskName(projectPath, extension.getCompileTaskName()); + String compileTaskName = + SourceSetUtils.getFullTaskName(projectPath, extension.getCompileTaskName()); taskNames.add(compileTaskName); srcDirs.addAll(extension.getSourceDirs()); @@ -302,31 +306,6 @@ private Collection getSourceSetContainer(Project project) { return new LinkedList<>(); } - /** - * Return a project task name - [project path]:[task]. - */ - private String getFullTaskName(String modulePath, String taskName) { - if (taskName == null) { - return null; - } - if (taskName.isEmpty()) { - return taskName; - } - - if (modulePath == null || modulePath.equals(":")) { - // must be prefixed with ":" as taskPaths are reported back like that in progress messages - return ":" + taskName; - } - return modulePath + ":" + taskName; - } - - private String stripPathPrefix(String projectPath) { - if (projectPath.startsWith(":")) { - return projectPath.substring(1); - } - return projectPath; - } - private Set getArchiveSourcePaths(CopySpec copySpec) { Set sourcePaths = new HashSet<>(); if (copySpec instanceof DefaultCopySpec) { diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java index 42550014..fe1427b7 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java @@ -29,6 +29,8 @@ import java.util.Set; import java.util.stream.Collectors; +// WORK IN PROGRESS + /** * TODO: JavaDoc. */ diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java index 6a594ee9..a6946f06 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java @@ -18,7 +18,7 @@ import java.util.Set; /** - * TODO: JavaDoc. + * Utility class for android related operations. */ public class AndroidUtils { @@ -26,14 +26,19 @@ private AndroidUtils() { } /** - * TODO: JavaDoc. + * Checks if the given project is an Android project. + * + * @param project Gradle project to check */ public static boolean isAndroidProject(Project project) { return getAndroidExtension(project) != null; } /** - * TODO: JavaDoc. + * Extracts build variants from the given Android project and converts + * them into list of GradleSourceSets. + * + * @param project Gradle project for extracting the build variants */ @SuppressWarnings("unchecked") public static List getBuildVariantsAsGradleSourceSets(Project project) { @@ -88,6 +93,12 @@ public static List getBuildVariantsAsGradleSourceSets(Project p } + /** + * Returns a GradleSourceSet populated with the given Android build variant data. + * + * @param project Gradle project to populate GradleSourceSet properties + * @param variant Android Build Variant object to populate GradleSourceSet properties + */ @SuppressWarnings("unchecked") private static GradleSourceSet convertVariantToGradleSourceSet(Project project, Object variant) { @@ -108,17 +119,17 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, // classes task equivalent in android (assembleRelease) gradleSourceSet.setClassesTaskName( - getFullTaskName(projectPath, "assemble" + capitalize(variantName)) + SourceSetUtils.getFullTaskName(projectPath, "assemble" + capitalize(variantName)) ); - gradleSourceSet.setCleanTaskName(getFullTaskName(projectPath, "clean")); + gradleSourceSet.setCleanTaskName(SourceSetUtils.getFullTaskName(projectPath, "clean")); // compile task in android (compileReleaseJavaWithJavac) HashSet tasks = new HashSet<>(); tasks.add("compile" + capitalize(variantName) + "JavaWithJavac"); gradleSourceSet.setTaskNames(tasks); - String projectName = stripPathPrefix(projectPath); + String projectName = SourceSetUtils.stripPathPrefix(projectPath); if (projectName.isEmpty()) { projectName = project.getName(); } @@ -222,11 +233,15 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, .getMethod("getRClassOutputJar").invoke(processResourcesTask); RegularFile file = (RegularFile) output.getClass() .getMethod("get").invoke(output); - classpathFiles.add(file.getAsFile()); + File jarFile = file.getAsFile(); + if (jarFile.exists()) { + classpathFiles.add(jarFile); + } } gradleSourceSet.setCompileClasspath(new LinkedList<>(classpathFiles)); - // TODO: Set Archive output dirs + // Archive output dirs (not relevant in case of android build variants) + gradleSourceSet.setArchiveOutputFiles(new HashMap<>()); // has tests Object unitTestVariant = variant.getClass().getMethod("getUnitTestVariant").invoke(variant); @@ -241,6 +256,11 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, } + /** + * Extracts the AndroidExtension from the given project. + * + * @param project Gradle project to extract the AndroidExtension object. + */ private static Object getAndroidExtension(Project project) { Object extension = null; @@ -258,6 +278,11 @@ private static Object getAndroidExtension(Project project) { } + /** + * Returns the AndroidProjectType based on the plugin applied to the given project. + * + * @param project Gradle project to check for plugin and return the corresponding project type. + */ private static AndroidProjectType getProjectType(Project project) { if (getAndroidExtension(project) == null) { @@ -282,11 +307,20 @@ private static AndroidProjectType getProjectType(Project project) { } + /** + * Extracts the given property from the given object with {@code getProperty} method. + * + * @param obj object from which the property is to be extracted + * @param propertyName name of the property to be extracted + */ public static Object getProperty(Object obj, String propertyName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { return obj.getClass().getMethod("getProperty", String.class).invoke(obj, propertyName); } + /** + * Enum class representing different types of Android projects. + */ private enum AndroidProjectType { APPLICATION, LIBRARY, @@ -295,31 +329,11 @@ private enum AndroidProjectType { ANDROID_TEST } - private static String stripPathPrefix(String projectPath) { - if (projectPath.startsWith(":")) { - return projectPath.substring(1); - } - return projectPath; - } - /** - * Return a project task name - [project path]:[task]. + * Returns the given string with its first letter capitalized. + * + * @param s String to capitalize */ - private static String getFullTaskName(String modulePath, String taskName) { - if (taskName == null) { - return null; - } - if (taskName.isEmpty()) { - return taskName; - } - - if (modulePath == null || modulePath.equals(":")) { - // must be prefixed with ":" as taskPaths are reported back like that in progress messages - return ":" + taskName; - } - return modulePath + ":" + taskName; - } - private static String capitalize(String s) { return s.substring(0, 1).toUpperCase() + s.substring(1); } diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java new file mode 100644 index 00000000..2bd7d7f6 --- /dev/null +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java @@ -0,0 +1,44 @@ +package com.microsoft.java.bs.gradle.plugin.utils; + +/** + * Utility class for common source set operations. + */ +public class SourceSetUtils { + + private SourceSetUtils() { + } + + /** + * Returns the gradle project path without the initial {@code :}. + * + * @param projectPath project path to operate upon + */ + public static String stripPathPrefix(String projectPath) { + if (projectPath.startsWith(":")) { + return projectPath.substring(1); + } + return projectPath; + } + + /** + * Return a project task name - [project path]:[task]. + * + * @param modulePath path of project module + * @param taskName name of gradle task + */ + public static String getFullTaskName(String modulePath, String taskName) { + if (taskName == null) { + return null; + } + if (taskName.isEmpty()) { + return taskName; + } + + if (modulePath == null || modulePath.equals(":")) { + // must be prefixed with ":" as taskPaths are reported back like that in progress messages + return ":" + taskName; + } + return modulePath + ":" + taskName; + } + +} From 90a8abfbae35fc7736f01f5310f7115cc4bd44ff Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:05:24 +0530 Subject: [PATCH 09/15] Complete Android GradleSourceSet and ModelBuilder unit test. Changes: - Removed unnecessary resource files from android-test project. - Completed AndroidModelBuilder unit test in GradleApiConnectorTest. - Suppressed and addressed minor warnings in DependencyCollector and SourceSetsModelBuilder. - Removed classloader approach for retrieving artifact components in AndroidDependencyCollector. - AndroidBuildVariant SourceSet now stores full task name for compileTask. - AndroidSDK Jar is also added to AndroidBuildVariant SourceSet compileClasspath. --- .../gradle/plugin/SourceSetsModelBuilder.java | 5 +- .../AndroidDependencyCollector.java | 91 +++++++----------- .../dependency/DependencyCollector.java | 20 ++-- .../bs/gradle/plugin/utils/AndroidUtils.java | 41 +++++++- .../gradle/GradleApiConnectorTest.java | 20 +++- .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 1404 -> 0 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 2898 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 982 -> 0 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 1772 -> 0 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 1900 -> 0 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 3918 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 2884 -> 0 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 5914 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 3844 -> 0 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 7778 -> 0 bytes .../{mipmap-anydpi => mipmap}/ic_launcher.xml | 0 .../ic_launcher_round.xml | 0 .../app/src/main/res/values-night/themes.xml | 16 --- .../app/src/main/res/values/colors.xml | 10 -- .../app/src/main/res/values/themes.xml | 16 --- .../app/src/main/res/xml/backup_rules.xml | 13 --- .../main/res/xml/data_extraction_rules.xml | 19 ---- .../java/com/example/mylibrary/Greeting.java | 9 ++ 23 files changed, 113 insertions(+), 147 deletions(-) delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-mdpi/ic_launcher.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp delete mode 100644 testProjects/android-test/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp rename testProjects/android-test/app/src/main/res/{mipmap-anydpi => mipmap}/ic_launcher.xml (100%) rename testProjects/android-test/app/src/main/res/{mipmap-anydpi => mipmap}/ic_launcher_round.xml (100%) delete mode 100644 testProjects/android-test/app/src/main/res/values-night/themes.xml delete mode 100644 testProjects/android-test/app/src/main/res/values/colors.xml delete mode 100644 testProjects/android-test/app/src/main/res/values/themes.xml delete mode 100644 testProjects/android-test/app/src/main/res/xml/backup_rules.xml delete mode 100644 testProjects/android-test/app/src/main/res/xml/data_extraction_rules.xml create mode 100644 testProjects/android-test/mylibrary/src/main/java/com/example/mylibrary/Greeting.java diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java index 96451398..a5fdaf0d 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java @@ -39,7 +39,6 @@ import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSet; import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSets; import com.microsoft.java.bs.gradle.plugin.dependency.DependencyCollector; -import org.jetbrains.annotations.NotNull; /** * The model builder for Gradle source sets. @@ -50,8 +49,9 @@ public boolean canBuild(String modelName) { return modelName.equals(GradleSourceSets.class.getName()); } + @SuppressWarnings("NullableProblems") @Override - public @NotNull Object buildAll(@NotNull String modelName, @NotNull Project project) { + public Object buildAll(String modelName, Project project) { // mapping Gradle source set to our customized model. List sourceSets; @@ -213,6 +213,7 @@ private Set tasksWithType(Project project, Class clazz) { * get all archive tasks for this project and maintain the archive file * to source set mapping. */ + @SuppressWarnings("deprecation") private Map> getArchiveOutputFiles(Project project, SourceSet sourceSet) { // get all archive tasks for this project and find the dirs that are included in the archive Set archiveTasks = tasksWithType(project, AbstractArchiveTask.class); diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java index fe1427b7..960d2e27 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/AndroidDependencyCollector.java @@ -12,11 +12,11 @@ import org.gradle.api.artifacts.result.ArtifactResult; import org.gradle.api.artifacts.result.ComponentArtifactsResult; import org.gradle.api.artifacts.result.ResolvedArtifactResult; -import org.gradle.api.component.Component; import org.gradle.api.specs.Specs; import org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier; import org.gradle.internal.component.local.model.ComponentFileArtifactIdentifier; import org.gradle.internal.component.local.model.OpaqueComponentArtifactIdentifier; +import org.gradle.jvm.JvmLibrary; import org.gradle.language.base.artifact.SourcesArtifact; import org.gradle.language.java.artifact.JavadocArtifact; @@ -29,10 +29,8 @@ import java.util.Set; import java.util.stream.Collectors; -// WORK IN PROGRESS - /** - * TODO: JavaDoc. + * Collects dependencies from an Android build variant. */ public class AndroidDependencyCollector { @@ -43,7 +41,6 @@ public class AndroidDependencyCollector { */ public static Set getModuleDependencies(Project project, Object variant) { Set dependencies = new HashSet<>(); - ClassLoader agpClassLoader = variant.getClass().getClassLoader(); try { // Retrieve and process compile configuration @@ -51,8 +48,7 @@ public static Set getModuleDependencies(Project project, (Configuration) AndroidUtils.getProperty(variant, "compileConfiguration"); dependencies.addAll(resolveConfigurationDependencies( project, - compileConfiguration, - agpClassLoader) + compileConfiguration) ); // Retrieve and process runtime configuration @@ -60,8 +56,7 @@ public static Set getModuleDependencies(Project project, (Configuration) AndroidUtils.getProperty(variant, "runtimeConfiguration"); dependencies.addAll(resolveConfigurationDependencies( project, - runtimeConfiguration, - agpClassLoader) + runtimeConfiguration) ); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); @@ -75,8 +70,7 @@ public static Set getModuleDependencies(Project project, */ private static Set resolveConfigurationDependencies( Project project, - Configuration configuration, - ClassLoader agpClassLoader + Configuration configuration ) { return configuration.getIncoming() .artifactView(viewConfiguration -> { @@ -86,15 +80,14 @@ private static Set resolveConfigurationDependencies( .getArtifacts() .getArtifacts() .stream() - .map(artifactResult -> getArtifact(project, artifactResult, agpClassLoader)) + .map(artifactResult -> getArtifact(project, artifactResult)) .filter(Objects::nonNull) .collect(Collectors.toSet()); } private static DefaultGradleModuleDependency getArtifact( Project project, - ResolvedArtifactResult artifactResult, - ClassLoader agpClassLoader + ResolvedArtifactResult artifactResult ) { ComponentArtifactIdentifier id = artifactResult.getId(); File artifactFile = artifactResult.getFile(); @@ -102,8 +95,7 @@ private static DefaultGradleModuleDependency getArtifact( return getModuleArtifactDependency( project, (ModuleComponentArtifactIdentifier) id, - artifactFile, - agpClassLoader + artifactFile ); } if (id instanceof OpaqueComponentArtifactIdentifier) { @@ -115,54 +107,45 @@ private static DefaultGradleModuleDependency getArtifact( return null; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "UnstableApiUsage"}) private static DefaultGradleModuleDependency getModuleArtifactDependency( Project project, ModuleComponentArtifactIdentifier artifactIdentifier, - File resolvedArtifactFile, - ClassLoader agpClassLoader + File resolvedArtifactFile ) { - try { - Class androidLibClazz = - (Class) agpClassLoader - .loadClass("com.android.build.api.variant.LibraryVariant"); - - ArtifactResolutionResult resolutionResult = project.getDependencies() - .createArtifactResolutionQuery() - .forComponents(artifactIdentifier.getComponentIdentifier()) - .withArtifacts( - androidLibClazz /* componentType */, - JavadocArtifact.class, SourcesArtifact.class /*artifactTypes*/ - ) - .execute(); - - List artifacts = new LinkedList<>(); - if (resolvedArtifactFile != null) { - artifacts.add(new DefaultArtifact(resolvedArtifactFile.toURI(), null)); - } + ArtifactResolutionResult resolutionResult = project.getDependencies() + .createArtifactResolutionQuery() + .forComponents(artifactIdentifier.getComponentIdentifier()) + .withArtifacts( + JvmLibrary.class /* componentType */, + JavadocArtifact.class, SourcesArtifact.class /*artifactTypes*/ + ) + .execute(); - Set resolvedComponents = resolutionResult.getResolvedComponents(); - File sourceJar = getNonClassesArtifact(resolvedComponents, SourcesArtifact.class); - if (sourceJar != null) { - artifacts.add(new DefaultArtifact(sourceJar.toURI(), "sources")); - } + List artifacts = new LinkedList<>(); + if (resolvedArtifactFile != null) { + artifacts.add(new DefaultArtifact(resolvedArtifactFile.toURI(), null)); + } - File javaDocJar = getNonClassesArtifact(resolvedComponents, JavadocArtifact.class); - if (javaDocJar != null) { - artifacts.add(new DefaultArtifact(javaDocJar.toURI(), "javadoc")); - } + Set resolvedComponents = resolutionResult.getResolvedComponents(); + File sourceJar = getNonClassesArtifact(resolvedComponents, SourcesArtifact.class); + if (sourceJar != null) { + artifacts.add(new DefaultArtifact(sourceJar.toURI(), "sources")); + } - return new DefaultGradleModuleDependency( - artifactIdentifier.getComponentIdentifier().getGroup(), - artifactIdentifier.getComponentIdentifier().getModule(), - artifactIdentifier.getComponentIdentifier().getVersion(), - artifacts - ); - } catch (ClassNotFoundException e) { - return null; + File javaDocJar = getNonClassesArtifact(resolvedComponents, JavadocArtifact.class); + if (javaDocJar != null) { + artifacts.add(new DefaultArtifact(javaDocJar.toURI(), "javadoc")); } + return new DefaultGradleModuleDependency( + artifactIdentifier.getComponentIdentifier().getGroup(), + artifactIdentifier.getComponentIdentifier().getModule(), + artifactIdentifier.getComponentIdentifier().getVersion(), + artifacts + ); + } private static File getNonClassesArtifact( diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/DependencyCollector.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/DependencyCollector.java index b952831a..cc6a7b01 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/DependencyCollector.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/dependency/DependencyCollector.java @@ -4,6 +4,7 @@ package com.microsoft.java.bs.gradle.plugin.dependency; import java.io.File; +import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -18,7 +19,6 @@ import org.gradle.api.artifacts.ResolvedArtifact; import org.gradle.api.artifacts.ResolvedConfiguration; import org.gradle.api.artifacts.component.ComponentArtifactIdentifier; -import org.gradle.api.artifacts.component.ComponentIdentifier; import org.gradle.api.artifacts.result.ArtifactResolutionResult; import org.gradle.api.artifacts.result.ArtifactResult; import org.gradle.api.artifacts.result.ComponentArtifactsResult; @@ -111,20 +111,18 @@ private static DefaultGradleModuleDependency getArtifact(Project project, } private static List getConfigurationArtifacts(Configuration config) { - return config.getIncoming() - .artifactView(viewConfiguration -> { - viewConfiguration.lenient(true); - viewConfiguration.componentFilter(Specs.satisfyAll()); - }) - .getArtifacts() // get ArtifactCollection from ArtifactView. - .getArtifacts() // get a set of ResolvedArtifactResult from ArtifactCollection. - .stream() - .collect(Collectors.toList()); + return new ArrayList<>(config.getIncoming() + .artifactView(viewConfiguration -> { + viewConfiguration.lenient(true); + viewConfiguration.componentFilter(Specs.satisfyAll()); + }) + .getArtifacts() // get ArtifactCollection from ArtifactView. + .getArtifacts()); } private static DefaultGradleModuleDependency getModuleArtifactDependency(Project project, ModuleComponentArtifactIdentifier artifactIdentifier, File resolvedArtifactFile) { - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "UnstableApiUsage"}) ArtifactResolutionResult resolutionResult = project.getDependencies() .createArtifactResolutionQuery() .forComponents(artifactIdentifier.getComponentIdentifier()) diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java index a6946f06..6e6aa819 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.LinkedList; import java.util.Set; +import java.util.stream.Collectors; /** * Utility class for android related operations. @@ -126,7 +127,8 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, // compile task in android (compileReleaseJavaWithJavac) HashSet tasks = new HashSet<>(); - tasks.add("compile" + capitalize(variantName) + "JavaWithJavac"); + String compileTaskName = "compile" + capitalize(variantName) + "JavaWithJavac"; + tasks.add(SourceSetUtils.getFullTaskName(projectPath, compileTaskName)); gradleSourceSet.setTaskNames(tasks); String projectName = SourceSetUtils.stripPathPrefix(projectPath); @@ -136,7 +138,7 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, String displayName = projectName + " [" + variantName + ']'; gradleSourceSet.setDisplayName(displayName); - // TODO: Set Module dependencies + // module dependencies Set moduleDependencies = AndroidDependencyCollector.getModuleDependencies(project, variant); gradleSourceSet.setModuleDependencies(moduleDependencies); @@ -225,6 +227,20 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, .getMethod("getCompileConfiguration").invoke(variant); Set classpathFiles = (Set) compileConfig.getClass() .getMethod("getFiles").invoke(compileConfig); + // add Android SDK + Object androidComponents = getAndroidComponentExtension(project); + if (androidComponents != null) { + Object sdkComponents = getProperty(androidComponents, "sdkComponents"); + Object bootClasspath = ((Provider) getProperty(sdkComponents, "bootclasspathProvider")).get(); + try { + List bootClasspathFiles = (List) bootClasspath.getClass().getMethod("get").invoke(bootClasspath); + List sdkClasspath = bootClasspathFiles.stream().map(RegularFile::getAsFile).collect(Collectors.toList()); + classpathFiles.addAll(sdkClasspath); + } catch (IllegalStateException | InvocationTargetException e) { + // failed to retrieve android sdk classpath + // do nothing + } + } // add R.jar file String taskName = "process" + capitalize(variantName) + "Resources"; Task processResourcesTask = project.getTasks().findByName(taskName); @@ -262,20 +278,37 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, * @param project Gradle project to extract the AndroidExtension object. */ private static Object getAndroidExtension(Project project) { + return getExtension(project, "android"); + } + + /** + * Extracts the AndroidComponentsExtension from the given project. + * + * @param project Gradle project to extract the AndroidComponentsExtension object. + */ + private static Object getAndroidComponentExtension(Project project) { + return getExtension(project, "androidComponents"); + } + /** + * Extracts the given extension from the given project. + * + * @param project Gradle project to extract the extension object. + * @param extensionName Name of the extension to extract. + */ + private static Object getExtension(Project project, String extensionName) { Object extension = null; try { Object convention = project.getClass().getMethod("getConvention").invoke(project); Object extensionMap = convention.getClass().getMethod("getAsMap").invoke(convention); extension = extensionMap.getClass() - .getMethod("get", Object.class).invoke(extensionMap, "android"); + .getMethod("get", Object.class).invoke(extensionMap, extensionName); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { // do nothing } return extension; - } /** diff --git a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java index b3dfdb49..db4bd50e 100644 --- a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java +++ b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java @@ -22,6 +22,7 @@ import com.microsoft.java.bs.core.Launcher; import com.microsoft.java.bs.core.internal.managers.PreferenceManager; import com.microsoft.java.bs.core.internal.model.Preferences; +import com.microsoft.java.bs.gradle.model.GradleModuleDependency; import com.microsoft.java.bs.gradle.model.GradleSourceSet; import com.microsoft.java.bs.gradle.model.GradleSourceSets; import com.microsoft.java.bs.gradle.model.ScalaExtension; @@ -93,14 +94,29 @@ void testGetGradleSourceSets() { } @Test - void testGetAndroidSourceSets() { + void testAndroidSourceSets() { + // NOTE: Create a `local.properties` file in the android-test project + // and configure the `sdk.dir` property File projectDir = projectPath.resolve("android-test").toFile(); PreferenceManager preferenceManager = new PreferenceManager(); preferenceManager.setPreferences(new Preferences()); GradleApiConnector connector = new GradleApiConnector(preferenceManager); GradleSourceSets gradleSourceSets = connector.getGradleSourceSets(projectDir.toURI(), null); assertEquals(4, gradleSourceSets.getGradleSourceSets().size()); - // TODO: Verify if complete source sets were retrieved + findSourceSet(gradleSourceSets, "app [debug]"); + findSourceSet(gradleSourceSets, "app [release]"); + findSourceSet(gradleSourceSets, "mylibrary [debug]"); + findSourceSet(gradleSourceSets, "mylibrary [release]"); + Set combinedModuleDependencies = new HashSet<>(); + for (GradleSourceSet sourceSet : gradleSourceSets.getGradleSourceSets()) { + assertEquals(2, sourceSet.getSourceDirs().size()); + assertEquals(4, sourceSet.getResourceDirs().size()); + assertEquals(0, sourceSet.getExtensions().size()); + assertEquals(0, sourceSet.getArchiveOutputFiles().size()); + assertTrue(sourceSet.hasTests()); + combinedModuleDependencies.addAll(sourceSet.getModuleDependencies()); + } + assertEquals(87, combinedModuleDependencies.size()); } private GradleSourceSet findSourceSet(GradleSourceSets gradleSourceSets, String displayName) { diff --git a/testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher.webp deleted file mode 100644 index c209e78ecd372343283f4157dcfd918ec5165bb3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1404 zcmV-?1%vuhNk&F=1pok7MM6+kP&il$0000G0000-002h-06|PpNX!5L00Dqw+t%{r zzW2vH!KF=w&cMnnN@{whkTw+#mAh0SV?YL=)3MimFYCWp#fpdtz~8$hD5VPuQgtcN zXl<@<#Cme5f5yr2h%@8TWh?)bSK`O z^Z@d={gn7J{iyxL_y_%J|L>ep{dUxUP8a{byupH&!UNR*OutO~0{*T4q5R6@ApLF! z5{w?Z150gC7#>(VHFJZ-^6O@PYp{t!jH(_Z*nzTK4 zkc{fLE4Q3|mA2`CWQ3{8;gxGizgM!zccbdQoOLZc8hThi-IhN90RFT|zlxh3Ty&VG z?Fe{#9RrRnxzsu|Lg2ddugg7k%>0JeD+{XZ7>Z~{=|M+sh1MF7~ zz>To~`~LVQe1nNoR-gEzkpe{Ak^7{{ZBk2i_<+`Bq<^GB!RYG+z)h;Y3+<{zlMUYd zrd*W4w&jZ0%kBuDZ1EW&KLpyR7r2=}fF2%0VwHM4pUs}ZI2egi#DRMYZPek*^H9YK zay4Iy3WXFG(F14xYsoDA|KXgGc5%2DhmQ1gFCkrgHBm!lXG8I5h*uf{rn48Z!_@ z4Bk6TJAB2CKYqPjiX&mWoW>OPFGd$wqroa($ne7EUK;#3VYkXaew%Kh^3OrMhtjYN?XEoY`tRPQsAkH-DSL^QqyN0>^ zmC>{#F14jz4GeW{pJoRpLFa_*GI{?T93^rX7SPQgT@LbLqpNA}<@2wH;q493)G=1Y z#-sCiRNX~qf3KgiFzB3I>4Z%AfS(3$`-aMIBU+6?gbgDb!)L~A)je+;fR0jWLL-Fu z4)P{c7{B4Hp91&%??2$v9iRSFnuckHUm}or9seH6 z>%NbT+5*@L5(I9j@06@(!{ZI?U0=pKn8uwIg&L{JV14+8s2hnvbRrU|hZCd}IJu7*;;ECgO%8_*W Kmw_-CKmY()leWbG diff --git a/testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/testProjects/android-test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp deleted file mode 100644 index b2dfe3d1ba5cf3ee31b3ecc1ced89044a1f3b7a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2898 zcmV-Y3$650Nk&FW3jhFDMM6+kP&il$0000G0000-002h-06|PpNWB9900E$G+qN-D z+81ABX7q?;bwx%xBg?kcwr$(C-Tex-ZCkHUw(Y9#+`E5-zuONG5fgw~E2WDng@Bc@ z24xy+R1n%~6xI#u9vJ8zREI)sb<&Il(016}Z~V1n^PU3-_H17A*Bf^o)&{_uBv}Py zulRfeE8g(g6HFhk_?o_;0@tz?1I+l+Y#Q*;RVC?(ud`_cU-~n|AX-b`JHrOIqn(-t&rOg-o`#C zh0LPxmbOAEb;zHTu!R3LDh1QO zZTf-|lJNUxi-PpcbRjw3n~n-pG;$+dIF6eqM5+L();B2O2tQ~|p{PlpNcvDbd1l%c zLtXn%lu(3!aNK!V#+HNn_D3lp z2%l+hK-nsj|Bi9;V*WIcQRTt5j90A<=am+cc`J zTYIN|PsYAhJ|=&h*4wI4ebv-C=Be#u>}%m;a{IGmJDU`0snWS&$9zdrT(z8#{OZ_Y zxwJx!ZClUi%YJjD6Xz@OP8{ieyJB=tn?>zaI-4JN;rr`JQbb%y5h2O-?_V@7pG_+y z(lqAsqYr!NyVb0C^|uclHaeecG)Sz;WV?rtoqOdAAN{j%?Uo%owya(F&qps@Id|Of zo@~Y-(YmfB+chv^%*3g4k3R0WqvuYUIA+8^SGJ{2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-6}=5k6suNfdLt*dt8D| z%H#$k)z#ZRcf|zDWB|pn<3+7Nz>?WW9WdkO5(a^m+D4WRJ9{wc>Y}IN)2Kbgn;_O? zGqdr&9~|$Y0tP=N(k7^Eu;iO*w+f%W`20BNo)=Xa@M_)+o$4LXJyiw{F?a633SC{B zl~9FH%?^Rm*LVz`lkULs)%idDX^O)SxQol(3jDRyBVR!7d`;ar+D7do)jQ}m`g$TevUD5@?*P8)voa?kEe@_hl{_h8j&5eB-5FrYW&*FHVt$ z$kRF9Nstj%KRzpjdd_9wO=4zO8ritN*NPk_9avYrsF(!4))tm{Ga#OY z(r{0buexOzu7+rw8E08Gxd`LTOID{*AC1m*6Nw@osfB%0oBF5sf<~wH1kL;sd zo)k6^VyRFU`)dt*iX^9&QtWbo6yE8XXH?`ztvpiOLgI3R+=MOBQ9=rMVgi<*CU%+d1PQQ0a1U=&b0vkF207%xU0ssI2 diff --git a/testProjects/android-test/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/testProjects/android-test/app/src/main/res/mipmap-mdpi/ic_launcher.webp deleted file mode 100644 index 4f0f1d64e58ba64d180ce43ee13bf9a17835fbca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 982 zcmV;{11bDcNk&G_0{{S5MM6+kP&il$0000G0000l001ul06|PpNU8t;00Dqo+t#w^ z^1csucXz7-Qrhzl9HuHB%l>&>1tG2^vb*E&k^T3$FG1eQZ51g$uv4V+kI`0<^1Z@N zk?Jjh$olyC%l>)Xq;7!>{iBj&BjJ`P&$fsCfpve_epJOBkTF?nu-B7D!hO=2ZR}

C%4 zc_9eOXvPbC4kzU8YowIA8cW~Uv|eB&yYwAObSwL2vY~UYI7NXPvf3b+c^?wcs~_t{ ze_m66-0)^{JdOMKPwjpQ@Sna!*?$wTZ~su*tNv7o!gXT!GRgivP}ec?5>l1!7<(rT zds|8x(qGc673zrvYIz;J23FG{9nHMnAuP}NpAED^laz3mAN1sy+NXK)!6v1FxQ;lh zOBLA>$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n%6JY!zhp=Fg}Ga2|8 z52e1WU%^L1}15Ex0fF$e@eCT(()_P zvV?CA%#Sy08_U6VPt4EtmVQraWJX` zh=N|WQ>LgrvF~R&qOfB$!%D3cGv?;Xh_z$z7k&s4N)$WYf*k=|*jCEkO19{h_(%W4 zPuOqbCw`SeAX*R}UUsbVsgtuG?xs(#Ikx9`JZoQFz0n*7ZG@Fv@kZk`gzO$HoA9kN z8U5{-yY zvV{`&WKU2$mZeoBmiJrEdzUZAv1sRxpePdg1)F*X^Y)zp^Y*R;;z~vOv-z&)&G)JQ{m!C9cmziu1^nHA z`#`0c>@PnQ9CJKgC5NjJD8HM3|KC(g5nnCq$n0Gsu_DXk36@ql%npEye|?%RmG)

FJ$wK}0tWNB{uH;AM~i diff --git a/testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp deleted file mode 100644 index 948a3070fe34c611c42c0d3ad3013a0dce358be0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1900 zcmV-y2b1_xNk&Fw2LJ$9MM6+kP&il$0000G0001A003VA06|PpNH75a00DqwTbm-~ zullQTcXxO9ki!OCRx^i?oR|n!<8G0=kI^!JSjFi-LL*`V;ET0H2IXfU0*i>o6o6Gy zRq6Ap5(_{XLdXcL-MzlN`ugSdZY_`jXhcENAu)N_0?GhF))9R;E`!bo9p?g?SRgw_ zEXHhFG$0{qYOqhdX<(wE4N@es3VIo$%il%6xP9gjiBri+2pI6aY4 zJbgh-Ud|V%3O!IcHKQx1FQH(_*TK;1>FQWbt^$K1zNn^cczkBs=QHCYZ8b&l!UV{K z{L0$KCf_&KR^}&2Fe|L&?1I7~pBENnCtCuH3sjcx6$c zwqkNkru);ie``q+_QI;IYLD9OV0ZxkuyBz|5<$1BH|vtey$> z5oto4=l-R-Aaq`Dk0}o9N0VrkqW_#;!u{!bJLDq%0092{Ghe=F;(kn} z+sQ@1=UlX30+2nWjk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8^C{r0xd zp#a%}ht55dOq?yhwYPrtp-m1xXp;4X;)NhxxUpgP%XTLmO zcjaFva^}dP3$&sfFTIR_jC=2pHh9kpI@2(6V*GQo7Ws)`j)hd+tr@P~gR*2gO@+1? zG<`_tB+LJuF|SZ9tIec;h%}}6WClT`L>HSW?E{Hp1h^+mlbf_$9zA>!ug>NALJsO{ mU%z=YwVD?}XMya)Bp;vlyE5&E_6!fzx9pwrdz474!~g(M6R?N? diff --git a/testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/testProjects/android-test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp deleted file mode 100644 index 1b9a6956b3acdc11f40ce2bb3f6efbd845cc243f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3918 zcmV-U53%r4Nk&FS4*&pHMM6+kP&il$0000G0001A003VA06|PpNSy@$00HoY|G(*G z+qV7x14$dSO^Re!iqt-AAIE9iwr$(CZQJL$blA4B`>;C3fBY6Q8_YSjb2%a=fc}4E zrSzssacq<^nmW|Rs93PJni30R<8w<(bK_$LO4L?!_OxLl$}K$MUEllnMK|rg=f3;y z*?;3j|Nh>)p0JQ3A~rf(MibH2r+)3cyV1qF&;8m{w-S*y+0mM){KTK^M5}ksc`qX3 zy>rf^b>~l>SSHds8(I@hz3&PD@LmEs4&prkT=BjsBCXTMhN$_)+kvnl0bLKW5rEsj z*d#KXGDB4P&>etx0X+`R19yC=LS)j!mgs5M0L~+o-T~Jl!p!AJxnGAhV%~rhYUL4hlWhgES3Kb5oA&X z{}?3OBSS-{!v$nCIGj->(-TAG)8LR{htr41^gxsT8yqt2@DEG6Yl`Uma3Nd4;YUoW zTbkYl3CMU5ypMF3EIkYmWL|*BknM`0+Kq6CpvO(y$#j94e+q{vI{Zp8cV_6RK!`&C zob$*5Q|$IZ09dW=L!V zw@#2wviu|<#3lgGE8GEhcx+zBt`} zOwP8j9X%^f7i_bth4PiJ$LYtFJSCN$3xwDN;8mr*B;CJwB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kAz$Y?Sr)!GUOX}qTQ5aMh|wq1uq}~joWyKl=b_LboM#wi{CMuz5x6BKlA-qy++cM01D3b7`uD z#l6M4pI;JCypO8JZ6?U&wNxR!{4oB_ zlV!x9+-&Qy6{%MQ{~yoZGkKiTSC`YS_j22~G;xUV855g2&C(zm^V!(wpcm@zn{%!g z4}JGo(sGZ1O~to-}le

UmY2RIYtNPVDpE$%vda+HD#3m z&VuXJ{BK&Qe+rBa7eq}Q(bq|tn(RrJAk|ztj2(i{d>nmQnM?;HF2k&9sA6up5tmjl z7lySlzMbifH17-m-Lwa_F&e7nOH?ESi3#ckR3tsM+jsck3`oG!uMS}|eAwVXv>}qxwq?QY%QJ0}r@^;fhuUA9W z*BVl>TGo&N004@xSiwDUXUvp51sVmqO3m)=B55aPwf@0=e}cN+$-BdKxY`YrT_4)0 z_d10#i44Q*rFr8MC>*)v$EJvz``(pb{e&*6k+b zsMz%($|1+8hn8c2?P(l@;Rb&CsZeYoCI3?2!LqjbwPXW3z4G$Qfj=cT5Yb%vY0(AX oeb?AaKtwrnc|$|zzw9vfvn^aJJ!zd)XFXqqy0000001=f@-~a#s diff --git a/testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/testProjects/android-test/app/src/main/res/mipmap/ic_launcher.xml similarity index 100% rename from testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher.xml rename to testProjects/android-test/app/src/main/res/mipmap/ic_launcher.xml diff --git a/testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/testProjects/android-test/app/src/main/res/mipmap/ic_launcher_round.xml similarity index 100% rename from testProjects/android-test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml rename to testProjects/android-test/app/src/main/res/mipmap/ic_launcher_round.xml diff --git a/testProjects/android-test/app/src/main/res/values-night/themes.xml b/testProjects/android-test/app/src/main/res/values-night/themes.xml deleted file mode 100644 index 85765448..00000000 --- a/testProjects/android-test/app/src/main/res/values-night/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/values/colors.xml b/testProjects/android-test/app/src/main/res/values/colors.xml deleted file mode 100644 index f8c6127d..00000000 --- a/testProjects/android-test/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/values/themes.xml b/testProjects/android-test/app/src/main/res/values/themes.xml deleted file mode 100644 index 226985f2..00000000 --- a/testProjects/android-test/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/xml/backup_rules.xml b/testProjects/android-test/app/src/main/res/xml/backup_rules.xml deleted file mode 100644 index fa0f996d..00000000 --- a/testProjects/android-test/app/src/main/res/xml/backup_rules.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/xml/data_extraction_rules.xml b/testProjects/android-test/app/src/main/res/xml/data_extraction_rules.xml deleted file mode 100644 index 9ee9997b..00000000 --- a/testProjects/android-test/app/src/main/res/xml/data_extraction_rules.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/testProjects/android-test/mylibrary/src/main/java/com/example/mylibrary/Greeting.java b/testProjects/android-test/mylibrary/src/main/java/com/example/mylibrary/Greeting.java new file mode 100644 index 00000000..eb35b88f --- /dev/null +++ b/testProjects/android-test/mylibrary/src/main/java/com/example/mylibrary/Greeting.java @@ -0,0 +1,9 @@ +package com.example.mylibrary; + +public class Greeting { + + public void greet(String name) { + System.out.println("Hello " + name) + } + +} From 57a6c85dc0181147e9d36ae11a7fff89fb32ad66 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Fri, 23 Aug 2024 10:44:30 +0530 Subject: [PATCH 10/15] Refactored Android build target and added integration test. Changes: - Fixed android test project. - Added integration test to verify presence of android sdk component jar. - Moved android sdk component and R file from classpath to module dependency of a build target. --- .../bs/gradle/plugin/utils/AndroidUtils.java | 84 +++++++++++++------ .../gradle/GradleApiConnectorTest.java | 2 +- .../BuildTargetServiceIntegrationTest.java | 46 +++++++++- .../app/src/main/AndroidManifest.xml | 3 - .../java/com/example/mylibrary/Greeting.java | 2 +- 5 files changed, 103 insertions(+), 34 deletions(-) diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java index 6e6aa819..1589f213 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java @@ -1,7 +1,10 @@ package com.microsoft.java.bs.gradle.plugin.utils; +import com.microsoft.java.bs.gradle.model.Artifact; import com.microsoft.java.bs.gradle.model.GradleModuleDependency; import com.microsoft.java.bs.gradle.model.GradleSourceSet; +import com.microsoft.java.bs.gradle.model.impl.DefaultArtifact; +import com.microsoft.java.bs.gradle.model.impl.DefaultGradleModuleDependency; import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSet; import com.microsoft.java.bs.gradle.plugin.dependency.AndroidDependencyCollector; import org.gradle.api.Project; @@ -11,6 +14,7 @@ import java.io.File; import java.lang.reflect.InvocationTargetException; +import java.net.URI; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -141,6 +145,38 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, // module dependencies Set moduleDependencies = AndroidDependencyCollector.getModuleDependencies(project, variant); + // add Android SDK + Object androidComponents = getAndroidComponentExtension(project); + if (androidComponents != null) { + Object sdkComponents = getProperty(androidComponents, "sdkComponents"); + Object bootClasspath = + ((Provider) getProperty(sdkComponents, "bootclasspathProvider")).get(); + try { + List bootClasspathFiles = + (List) bootClasspath.getClass().getMethod("get").invoke(bootClasspath); + List sdkClasspath = + bootClasspathFiles.stream().map(RegularFile::getAsFile).collect(Collectors.toList()); + for (File file : sdkClasspath) { + moduleDependencies.add(mockModuleDependency(file.toURI())); + } + } catch (IllegalStateException | InvocationTargetException e) { + // failed to retrieve android sdk classpath + // do nothing + } + } + // add R.jar file + String taskName = "process" + capitalize(variantName) + "Resources"; + Task processResourcesTask = project.getTasks().findByName(taskName); + if (processResourcesTask != null) { + Object output = processResourcesTask.getClass() + .getMethod("getRClassOutputJar").invoke(processResourcesTask); + RegularFile file = (RegularFile) output.getClass() + .getMethod("get").invoke(output); + File jarFile = file.getAsFile(); + if (jarFile.exists()) { + moduleDependencies.add(mockModuleDependency(jarFile.toURI())); + } + } gradleSourceSet.setModuleDependencies(moduleDependencies); // extensions @@ -227,33 +263,6 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, .getMethod("getCompileConfiguration").invoke(variant); Set classpathFiles = (Set) compileConfig.getClass() .getMethod("getFiles").invoke(compileConfig); - // add Android SDK - Object androidComponents = getAndroidComponentExtension(project); - if (androidComponents != null) { - Object sdkComponents = getProperty(androidComponents, "sdkComponents"); - Object bootClasspath = ((Provider) getProperty(sdkComponents, "bootclasspathProvider")).get(); - try { - List bootClasspathFiles = (List) bootClasspath.getClass().getMethod("get").invoke(bootClasspath); - List sdkClasspath = bootClasspathFiles.stream().map(RegularFile::getAsFile).collect(Collectors.toList()); - classpathFiles.addAll(sdkClasspath); - } catch (IllegalStateException | InvocationTargetException e) { - // failed to retrieve android sdk classpath - // do nothing - } - } - // add R.jar file - String taskName = "process" + capitalize(variantName) + "Resources"; - Task processResourcesTask = project.getTasks().findByName(taskName); - if (processResourcesTask != null) { - Object output = processResourcesTask.getClass() - .getMethod("getRClassOutputJar").invoke(processResourcesTask); - RegularFile file = (RegularFile) output.getClass() - .getMethod("get").invoke(output); - File jarFile = file.getAsFile(); - if (jarFile.exists()) { - classpathFiles.add(jarFile); - } - } gradleSourceSet.setCompileClasspath(new LinkedList<>(classpathFiles)); // Archive output dirs (not relevant in case of android build variants) @@ -371,4 +380,25 @@ private static String capitalize(String s) { return s.substring(0, 1).toUpperCase() + s.substring(1); } + /** + * Mocks GradleModuleDependency with a single artifact. + * + * @param jarUri Uri for the artifact to include in the ModuleDependency object. + */ + private static GradleModuleDependency mockModuleDependency(URI jarUri) { + + final String unknown = "UNKNOWN"; + + List artifacts = new LinkedList<>(); + artifacts.add(new DefaultArtifact(jarUri, null)); + + return new DefaultGradleModuleDependency( + unknown, + unknown, + unknown, + artifacts + ); + + } + } diff --git a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java index db4bd50e..b7617415 100644 --- a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java +++ b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java @@ -116,7 +116,7 @@ void testAndroidSourceSets() { assertTrue(sourceSet.hasTests()); combinedModuleDependencies.addAll(sourceSet.getModuleDependencies()); } - assertEquals(87, combinedModuleDependencies.size()); + assertEquals(91, combinedModuleDependencies.size()); } private GradleSourceSet findSourceSet(GradleSourceSets gradleSourceSets, String displayName) { diff --git a/server/src/test/java/com/microsoft/java/bs/core/internal/server/BuildTargetServiceIntegrationTest.java b/server/src/test/java/com/microsoft/java/bs/core/internal/server/BuildTargetServiceIntegrationTest.java index 0ba95a69..f2df4e0d 100644 --- a/server/src/test/java/com/microsoft/java/bs/core/internal/server/BuildTargetServiceIntegrationTest.java +++ b/server/src/test/java/com/microsoft/java/bs/core/internal/server/BuildTargetServiceIntegrationTest.java @@ -7,6 +7,8 @@ import ch.epfl.scala.bsp4j.CompileParams; import ch.epfl.scala.bsp4j.CompileReport; import ch.epfl.scala.bsp4j.CompileResult; +import ch.epfl.scala.bsp4j.DependencyModule; +import ch.epfl.scala.bsp4j.DependencyModulesItem; import ch.epfl.scala.bsp4j.DependencyModulesParams; import ch.epfl.scala.bsp4j.DependencyModulesResult; import ch.epfl.scala.bsp4j.DependencySourcesParams; @@ -29,6 +31,8 @@ import ch.epfl.scala.bsp4j.extended.TestFinishEx; import ch.epfl.scala.bsp4j.extended.TestName; import ch.epfl.scala.bsp4j.extended.TestStartEx; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.microsoft.java.bs.core.internal.utils.JsonUtils; import org.junit.jupiter.api.Test; @@ -128,7 +132,7 @@ void testCompilingSingleProjectServer() { .buildTargetDependencySources(dependencySourcesParams).join(); assertEquals(2, dependencySourcesResult.getItems().size()); List allSources = dependencySourcesResult.getItems().stream() - .flatMap(item -> item.getSources().stream()).collect(Collectors.toList()); + .flatMap(item -> item.getSources().stream()).toList(); assertTrue(allSources.stream().anyMatch(source -> source.endsWith("-sources.jar"))); // check dependency modules @@ -143,7 +147,7 @@ void testCompilingSingleProjectServer() { MavenDependencyModule.class)) .flatMap(mavenDependencyModule -> mavenDependencyModule.getArtifacts().stream()) .filter(artifact -> "sources".equals(artifact.getClassifier())) - .collect(Collectors.toList()); + .toList(); assertTrue(allArtifacts.stream() .anyMatch(artifact -> artifact.getUri().endsWith("-sources.jar"))); @@ -1745,4 +1749,42 @@ void testExtraConfiguration() { }); } + @Test + void testAndroidBuildTargets() { + + withNewTestServer("android-test", (buildServer, client) -> { + + WorkspaceBuildTargetsResult buildTargetsResult = buildServer.workspaceBuildTargets().join(); + List btIds = buildTargetsResult.getTargets().stream() + .map(BuildTarget::getId) + .collect(Collectors.toList()); + + DependencyModulesResult dependencyModulesResultBefore = buildServer + .buildTargetDependencyModules(new DependencyModulesParams(btIds)).join(); + + for (DependencyModulesItem item : dependencyModulesResultBefore.getItems()) { + assertTrue(containsAndroidArtifactPath(item.getModules())); + } + + }); + + } + + private boolean containsAndroidArtifactPath(List modules) { + + for (DependencyModule module : modules) { + Object data = module.getData(); + if (data instanceof JsonObject) { + for (JsonElement artifact : ((JsonObject) data).getAsJsonArray("artifacts")) { + if (artifact.getAsJsonObject().get("uri").getAsString().endsWith("android.jar")) { + return true; + } + } + } + } + + return false; + + } + } diff --git a/testProjects/android-test/app/src/main/AndroidManifest.xml b/testProjects/android-test/app/src/main/AndroidManifest.xml index a7f9f2ca..8b248fe2 100644 --- a/testProjects/android-test/app/src/main/AndroidManifest.xml +++ b/testProjects/android-test/app/src/main/AndroidManifest.xml @@ -4,13 +4,10 @@ Date: Fri, 23 Aug 2024 13:32:17 +0530 Subject: [PATCH 11/15] Addressing Comments. Changes: - Removed default proguard files from android-test project. - Added a utility function for invocation of methods with reflection in AndroidUtils. --- .../bs/gradle/plugin/utils/AndroidUtils.java | 49 +++++++++---------- testProjects/android-test/app/build.gradle | 1 - .../android-test/app/proguard-rules.pro | 21 -------- .../android-test/mylibrary/build.gradle | 2 - .../android-test/mylibrary/consumer-rules.pro | 0 .../android-test/mylibrary/proguard-rules.pro | 21 -------- 6 files changed, 22 insertions(+), 72 deletions(-) delete mode 100644 testProjects/android-test/app/proguard-rules.pro delete mode 100644 testProjects/android-test/mylibrary/consumer-rules.pro delete mode 100644 testProjects/android-test/mylibrary/proguard-rules.pro diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java index 1589f213..507dbc8b 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java @@ -80,8 +80,7 @@ public static List getBuildVariantsAsGradleSourceSets(Project p } try { - Set variants = - (Set) androidExtension.getClass().getMethod(methodName).invoke(androidExtension); + Set variants = (Set) invokeMethod(androidExtension, methodName); for (Object variant : variants) { GradleSourceSet sourceSet = convertVariantToGradleSourceSet(project, variant); if (sourceSet == null) { @@ -119,7 +118,7 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, gradleSourceSet.setProjectDir(project.getProjectDir()); gradleSourceSet.setRootDir(project.getRootDir()); - String variantName = (String) variant.getClass().getMethod("getName").invoke(variant); + String variantName = (String) invokeMethod(variant, "getName"); gradleSourceSet.setSourceSetName(variantName); // classes task equivalent in android (assembleRelease) @@ -153,7 +152,7 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, ((Provider) getProperty(sdkComponents, "bootclasspathProvider")).get(); try { List bootClasspathFiles = - (List) bootClasspath.getClass().getMethod("get").invoke(bootClasspath); + (List) invokeMethod(bootClasspath, "get"); List sdkClasspath = bootClasspathFiles.stream().map(RegularFile::getAsFile).collect(Collectors.toList()); for (File file : sdkClasspath) { @@ -168,10 +167,8 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, String taskName = "process" + capitalize(variantName) + "Resources"; Task processResourcesTask = project.getTasks().findByName(taskName); if (processResourcesTask != null) { - Object output = processResourcesTask.getClass() - .getMethod("getRClassOutputJar").invoke(processResourcesTask); - RegularFile file = (RegularFile) output.getClass() - .getMethod("get").invoke(output); + Object output = invokeMethod(processResourcesTask, "getRClassOutputJar"); + RegularFile file = (RegularFile) invokeMethod(output, "get"); File jarFile = file.getAsFile(); if (jarFile.exists()) { moduleDependencies.add(mockModuleDependency(jarFile.toURI())); @@ -208,18 +205,15 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, (Provider) getProperty(variant, "processJavaResourcesProvider"); if (resourceProvider != null) { Task resTask = resourceProvider.get(); - File outputDir = - (File) resTask.getClass().getMethod("getDestinationDir").invoke(resTask); + File outputDir = (File) invokeMethod(resTask, "getDestinationDir"); resourceOutputs.add(outputDir); } Provider resProvider = (Provider) getProperty(variant, "mergeResourcesProvider"); if (resProvider != null) { Task resTask = resProvider.get(); - Object outputDir = - resTask.getClass().getMethod("getOutputDir").invoke(resTask); - File output = - ((Provider) outputDir.getClass().getMethod("getAsFile").invoke(outputDir)).get(); + Object outputDir = invokeMethod(resTask, "getOutputDir"); + File output = ((Provider) invokeMethod(outputDir, "getAsFile")).get(); resourceOutputs.add(output); } gradleSourceSet.setResourceOutputDirs(resourceOutputs); @@ -232,13 +226,11 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, if (javaCompileProvider != null) { Task javaCompileTask = javaCompileProvider.get(); - File outputDir = (File) javaCompileTask.getClass().getMethod("getDestinationDir") - .invoke(javaCompileTask); + File outputDir = (File) invokeMethod(javaCompileTask, "getDestinationDir"); sourceOutputs.add(outputDir); - Object source = javaCompileTask.getClass().getMethod("getSource").invoke(javaCompileTask); - Set compileSources = - (Set) source.getClass().getMethod("getFiles").invoke(source); + Object source = invokeMethod(javaCompileTask, "getSource"); + Set compileSources = (Set) invokeMethod(source, "getFiles"); // generated = compile source - source for (File compileSource : compileSources) { @@ -259,18 +251,16 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, gradleSourceSet.setSourceOutputDirs(sourceOutputs); // classpath - Object compileConfig = variant.getClass() - .getMethod("getCompileConfiguration").invoke(variant); - Set classpathFiles = (Set) compileConfig.getClass() - .getMethod("getFiles").invoke(compileConfig); + Object compileConfig = invokeMethod(variant, "getCompileConfiguration"); + Set classpathFiles = (Set) invokeMethod(compileConfig, "getFiles"); gradleSourceSet.setCompileClasspath(new LinkedList<>(classpathFiles)); // Archive output dirs (not relevant in case of android build variants) gradleSourceSet.setArchiveOutputFiles(new HashMap<>()); // has tests - Object unitTestVariant = variant.getClass().getMethod("getUnitTestVariant").invoke(variant); - Object testVariant = variant.getClass().getMethod("getTestVariant").invoke(variant); + Object unitTestVariant = invokeMethod(variant, "getUnitTestVariant"); + Object testVariant = invokeMethod(variant, "getTestVariant"); gradleSourceSet.setHasTests(unitTestVariant != null || testVariant != null); return gradleSourceSet; @@ -309,8 +299,8 @@ private static Object getExtension(Project project, String extensionName) { Object extension = null; try { - Object convention = project.getClass().getMethod("getConvention").invoke(project); - Object extensionMap = convention.getClass().getMethod("getAsMap").invoke(convention); + Object convention = invokeMethod(project, "getConvention"); + Object extensionMap = invokeMethod(convention, "getAsMap"); extension = extensionMap.getClass() .getMethod("get", Object.class).invoke(extensionMap, extensionName); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { @@ -401,4 +391,9 @@ private static GradleModuleDependency mockModuleDependency(URI jarUri) { } + private static Object invokeMethod(Object object, String methodName) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + return object.getClass().getMethod(methodName).invoke(object); + } + } diff --git a/testProjects/android-test/app/build.gradle b/testProjects/android-test/app/build.gradle index 2d12cba1..7f4c082a 100644 --- a/testProjects/android-test/app/build.gradle +++ b/testProjects/android-test/app/build.gradle @@ -19,7 +19,6 @@ android { buildTypes { release { minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { diff --git a/testProjects/android-test/app/proguard-rules.pro b/testProjects/android-test/app/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/testProjects/android-test/app/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/testProjects/android-test/mylibrary/build.gradle b/testProjects/android-test/mylibrary/build.gradle index 6bf974b8..097ab5ba 100644 --- a/testProjects/android-test/mylibrary/build.gradle +++ b/testProjects/android-test/mylibrary/build.gradle @@ -10,13 +10,11 @@ android { minSdk 26 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" } buildTypes { release { minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { diff --git a/testProjects/android-test/mylibrary/consumer-rules.pro b/testProjects/android-test/mylibrary/consumer-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/testProjects/android-test/mylibrary/proguard-rules.pro b/testProjects/android-test/mylibrary/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/testProjects/android-test/mylibrary/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file From 04ee668f23c8e64397b647fe3d63a92636eba3ef Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Fri, 23 Aug 2024 14:01:31 +0530 Subject: [PATCH 12/15] Removed all possible resource files from android-test project. --- .../app/src/main/AndroidManifest.xml | 3 - .../res/drawable/ic_launcher_background.xml | 170 ------------------ .../res/drawable/ic_launcher_foreground.xml | 30 ---- .../app/src/main/res/mipmap/ic_launcher.xml | 6 - .../src/main/res/mipmap/ic_launcher_round.xml | 6 - .../app/src/main/res/values/strings.xml | 3 - 6 files changed, 218 deletions(-) delete mode 100644 testProjects/android-test/app/src/main/res/drawable/ic_launcher_background.xml delete mode 100644 testProjects/android-test/app/src/main/res/drawable/ic_launcher_foreground.xml delete mode 100644 testProjects/android-test/app/src/main/res/mipmap/ic_launcher.xml delete mode 100644 testProjects/android-test/app/src/main/res/mipmap/ic_launcher_round.xml delete mode 100644 testProjects/android-test/app/src/main/res/values/strings.xml diff --git a/testProjects/android-test/app/src/main/AndroidManifest.xml b/testProjects/android-test/app/src/main/AndroidManifest.xml index 8b248fe2..49cdb934 100644 --- a/testProjects/android-test/app/src/main/AndroidManifest.xml +++ b/testProjects/android-test/app/src/main/AndroidManifest.xml @@ -4,9 +4,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testProjects/android-test/app/src/main/res/drawable/ic_launcher_foreground.xml b/testProjects/android-test/app/src/main/res/drawable/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d11..00000000 --- a/testProjects/android-test/app/src/main/res/drawable/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/mipmap/ic_launcher.xml b/testProjects/android-test/app/src/main/res/mipmap/ic_launcher.xml deleted file mode 100644 index 6f3b755b..00000000 --- a/testProjects/android-test/app/src/main/res/mipmap/ic_launcher.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/mipmap/ic_launcher_round.xml b/testProjects/android-test/app/src/main/res/mipmap/ic_launcher_round.xml deleted file mode 100644 index 6f3b755b..00000000 --- a/testProjects/android-test/app/src/main/res/mipmap/ic_launcher_round.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/testProjects/android-test/app/src/main/res/values/strings.xml b/testProjects/android-test/app/src/main/res/values/strings.xml deleted file mode 100644 index ad0d77d4..00000000 --- a/testProjects/android-test/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - AndroidTest - \ No newline at end of file From 368e8e970a7cb0a3c5640bbd99f3a3eddbd4df79 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Mon, 26 Aug 2024 22:41:46 +0530 Subject: [PATCH 13/15] Cleanup Changes: - Added needed notes to Android tests. - Removed unnecessary support dependency from android-test library project. --- .../core/internal/gradle/GradleApiConnectorTest.java | 12 +++++++++--- .../server/BuildTargetServiceIntegrationTest.java | 2 ++ testProjects/android-test/gradle/libs.versions.toml | 2 -- testProjects/android-test/mylibrary/build.gradle | 2 -- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java index b7617415..9e676335 100644 --- a/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java +++ b/server/src/test/java/com/microsoft/java/bs/core/internal/gradle/GradleApiConnectorTest.java @@ -95,8 +95,6 @@ void testGetGradleSourceSets() { @Test void testAndroidSourceSets() { - // NOTE: Create a `local.properties` file in the android-test project - // and configure the `sdk.dir` property File projectDir = projectPath.resolve("android-test").toFile(); PreferenceManager preferenceManager = new PreferenceManager(); preferenceManager.setPreferences(new Preferences()); @@ -116,7 +114,15 @@ void testAndroidSourceSets() { assertTrue(sourceSet.hasTests()); combinedModuleDependencies.addAll(sourceSet.getModuleDependencies()); } - assertEquals(91, combinedModuleDependencies.size()); + // This test can vary depending on the environment due to generated files. + // Specifically R file and Android Components. For eg: + // 1. When android-test project has not been or doesn't have the resources compiled + // the R.jar files don't exist for the build targets and are not included. + // 2. ANDROID_HOME is not configured in which case the Android Component classpath + // is not added to module dependencies. + + // 57 is the number of actual project module dependencies without test variant dependencies + assertTrue(combinedModuleDependencies.size() >= 57); } private GradleSourceSet findSourceSet(GradleSourceSets gradleSourceSets, String displayName) { diff --git a/server/src/test/java/com/microsoft/java/bs/core/internal/server/BuildTargetServiceIntegrationTest.java b/server/src/test/java/com/microsoft/java/bs/core/internal/server/BuildTargetServiceIntegrationTest.java index f2df4e0d..c412b29f 100644 --- a/server/src/test/java/com/microsoft/java/bs/core/internal/server/BuildTargetServiceIntegrationTest.java +++ b/server/src/test/java/com/microsoft/java/bs/core/internal/server/BuildTargetServiceIntegrationTest.java @@ -1752,6 +1752,8 @@ void testExtraConfiguration() { @Test void testAndroidBuildTargets() { + // NOTE: Requires Android SDK to be configured via ANDROID_HOME property + withNewTestServer("android-test", (buildServer, client) -> { WorkspaceBuildTargetsResult buildTargetsResult = buildServer.workspaceBuildTargets().join(); diff --git a/testProjects/android-test/gradle/libs.versions.toml b/testProjects/android-test/gradle/libs.versions.toml index 38e0e3be..abf6cd39 100644 --- a/testProjects/android-test/gradle/libs.versions.toml +++ b/testProjects/android-test/gradle/libs.versions.toml @@ -9,7 +9,6 @@ activity = "1.9.0" constraintlayout = "2.1.4" runner = "1.0.2" espressoCoreVersion = "3.0.2" -appcompatV7 = "28.0.0" [libraries] junit = { group = "junit", name = "junit", version.ref = "junit" } @@ -21,7 +20,6 @@ activity = { group = "androidx.activity", name = "activity", version.ref = "acti constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } runner = { group = "com.android.support.test", name = "runner", version.ref = "runner" } android-espresso-core = { group = "com.android.support.test.espresso", name = "espresso-core", version.ref = "espressoCoreVersion" } -appcompat-v7 = { group = "com.android.support", name = "appcompat-v7", version.ref = "appcompatV7" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } diff --git a/testProjects/android-test/mylibrary/build.gradle b/testProjects/android-test/mylibrary/build.gradle index 097ab5ba..f6e082ee 100644 --- a/testProjects/android-test/mylibrary/build.gradle +++ b/testProjects/android-test/mylibrary/build.gradle @@ -24,8 +24,6 @@ android { } dependencies { - - implementation libs.appcompat.v7 testImplementation libs.junit androidTestImplementation libs.runner androidTestImplementation libs.android.espresso.core From e919bfd72b2e48c3fedc968f354d993486a40d25 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:59:05 +0530 Subject: [PATCH 14/15] Added language extension to the android build targets for the client. Changes: - Moved supportedLanguageModelBuilders method from the ModelBuilder to AndroidUtils. - Added JavaLanguageExtension to the android build target extensions property. --- .../gradle/plugin/SourceSetsModelBuilder.java | 20 +-- .../bs/gradle/plugin/utils/AndroidUtils.java | 146 +++++++++++++++++- .../gradle/plugin/utils/SourceSetUtils.java | 34 ++++ 3 files changed, 179 insertions(+), 21 deletions(-) diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java index a5fdaf0d..ef351d25 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/SourceSetsModelBuilder.java @@ -35,7 +35,6 @@ import com.microsoft.java.bs.gradle.model.GradleSourceSet; import com.microsoft.java.bs.gradle.model.GradleSourceSets; import com.microsoft.java.bs.gradle.model.LanguageExtension; -import com.microsoft.java.bs.gradle.model.SupportedLanguages; import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSet; import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSets; import com.microsoft.java.bs.gradle.plugin.dependency.DependencyCollector; @@ -101,7 +100,8 @@ private DefaultGradleSourceSet getSourceSet(Project project, SourceSet sourceSet Set srcDirs = new HashSet<>(); Set generatedSrcDirs = new HashSet<>(); Set sourceOutputDirs = new HashSet<>(); - for (LanguageModelBuilder languageModelBuilder : getSupportedLanguages()) { + for (LanguageModelBuilder languageModelBuilder + : SourceSetUtils.getSupportedLanguageModelBuilders()) { LanguageExtension extension = languageModelBuilder.getExtensionFor(project, sourceSet, gradleSourceSet.getModuleDependencies()); if (extension != null) { @@ -185,22 +185,6 @@ private DefaultGradleSourceSet getSourceSet(Project project, SourceSet sourceSet return gradleSourceSet; } - private List getSupportedLanguages() { - List results = new LinkedList<>(); - String supportedLanguagesProps = System.getProperty("bsp.gradle.supportedLanguages"); - if (supportedLanguagesProps != null) { - String[] supportedLanguages = supportedLanguagesProps.split(","); - for (String language : supportedLanguages) { - if (language.equalsIgnoreCase(SupportedLanguages.JAVA.getBspName())) { - results.add(new JavaLanguageModelBuilder()); - } else if (language.equalsIgnoreCase(SupportedLanguages.SCALA.getBspName())) { - results.add(new ScalaLanguageModelBuilder()); - } - } - } - return results; - } - private Set tasksWithType(Project project, Class clazz) { // Gradle gives concurrentmodification exceptions if multiple threads resolve // the tasks concurrently, which happens on multi-project builds diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java index 507dbc8b..a7e70739 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java @@ -3,6 +3,9 @@ import com.microsoft.java.bs.gradle.model.Artifact; import com.microsoft.java.bs.gradle.model.GradleModuleDependency; import com.microsoft.java.bs.gradle.model.GradleSourceSet; +import com.microsoft.java.bs.gradle.model.LanguageExtension; +import com.microsoft.java.bs.gradle.model.SupportedLanguages; +import com.microsoft.java.bs.gradle.model.impl.DefaultJavaExtension; import com.microsoft.java.bs.gradle.model.impl.DefaultArtifact; import com.microsoft.java.bs.gradle.model.impl.DefaultGradleModuleDependency; import com.microsoft.java.bs.gradle.model.impl.DefaultGradleSourceSet; @@ -10,17 +13,29 @@ import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.file.RegularFile; +import org.gradle.api.internal.tasks.compile.DefaultJavaCompileSpec; +import org.gradle.api.internal.tasks.compile.JavaCompilerArgumentsBuilder; import org.gradle.api.provider.Provider; +import org.gradle.api.tasks.compile.CompileOptions; +import org.gradle.api.tasks.compile.JavaCompile; +import org.gradle.plugins.ide.internal.tooling.java.DefaultInstalledJdk; +import org.gradle.util.GradleVersion; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.LinkedList; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Utility class for android related operations. @@ -176,9 +191,6 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, } gradleSourceSet.setModuleDependencies(moduleDependencies); - // extensions - gradleSourceSet.setExtensions(new HashMap<>()); - // source and resource Object sourceSets = getProperty(variant, "sourceSets"); Set sourceDirs = new HashSet<>(); @@ -223,9 +235,12 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, Set sourceOutputs = new HashSet<>(); Provider javaCompileProvider = (Provider) getProperty(variant, "javaCompileProvider"); + List compilerArgs = new ArrayList<>(); if (javaCompileProvider != null) { Task javaCompileTask = javaCompileProvider.get(); + compilerArgs.addAll(getCompilerArgs((JavaCompile) javaCompileTask)); + File outputDir = (File) invokeMethod(javaCompileTask, "getDestinationDir"); sourceOutputs.add(outputDir); @@ -263,6 +278,29 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, Object testVariant = invokeMethod(variant, "getTestVariant"); gradleSourceSet.setHasTests(unitTestVariant != null || testVariant != null); + // extensions + Map extensions = new HashMap<>(); + boolean isJavaSupported = Arrays.stream(SourceSetUtils.getSupportedLanguages()) + .anyMatch(l -> Objects.equals(l, SupportedLanguages.JAVA.getBspName())); + if (isJavaSupported) { + DefaultJavaExtension extension = new DefaultJavaExtension(); + + extension.setJavaHome(DefaultInstalledJdk.current().getJavaHome()); + extension.setJavaVersion(DefaultInstalledJdk.current().getJavaVersion().getMajorVersion()); + + extension.setSourceDirs(sourceDirs); + extension.setGeneratedSourceDirs(generatedSources); + extension.setClassesDir(sourceOutputs.iterator().next()); + extension.setCompileTaskName(compileTaskName); + + extension.setCompilerArgs(compilerArgs); + extension.setSourceCompatibility(getSourceCompatibility(compilerArgs)); + extension.setTargetCompatibility(getTargetCompatibility(compilerArgs)); + + extensions.put(SupportedLanguages.JAVA.getBspName(), extension); + } + gradleSourceSet.setExtensions(extensions); + return gradleSourceSet; } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { @@ -396,4 +434,106 @@ private static Object invokeMethod(Object object, String methodName) return object.getClass().getMethod(methodName).invoke(object); } + // region TODO: Duplicate code from JavaLanguageModelBuilder + /** + * Get the compilation arguments of the build variant. + */ + private static List getCompilerArgs(JavaCompile javaCompile) { + CompileOptions options = javaCompile.getOptions(); + + try { + DefaultJavaCompileSpec specs = getJavaCompileSpec(javaCompile); + + JavaCompilerArgumentsBuilder builder = new JavaCompilerArgumentsBuilder(specs) + .includeMainOptions(true) + .includeClasspath(false) + .includeSourceFiles(false) + .includeLauncherOptions(false); + return builder.build(); + } catch (Exception e) { + // DefaultJavaCompileSpec and JavaCompilerArgumentsBuilder are internal so may not exist. + // Fallback to returning just the compiler arguments the build has specified. + // This will miss a lot of arguments derived from the CompileOptions e.g. sourceCompatibilty + // Arguments must be cast and converted to String because Groovy can use GStringImpl + // which then throws IllegalArgumentException when passed back over the tooling connection. + List compilerArgs = new LinkedList<>(options.getCompilerArgs()); + return compilerArgs + .stream() + .map(Object::toString) + .collect(Collectors.toList()); + } + } + + private static DefaultJavaCompileSpec getJavaCompileSpec(JavaCompile javaCompile) { + CompileOptions options = javaCompile.getOptions(); + + DefaultJavaCompileSpec specs = new DefaultJavaCompileSpec(); + specs.setCompileOptions(options); + + // check the project hasn't already got the target or source defined in the + // compiler args so they're not overwritten below + List originalArgs = options.getCompilerArgs(); + String argsSourceCompatibility = getSourceCompatibility(originalArgs); + String argsTargetCompatibility = getTargetCompatibility(originalArgs); + + if (!argsSourceCompatibility.isEmpty() && !argsTargetCompatibility.isEmpty()) { + return specs; + } + + if (GradleVersion.current().compareTo(GradleVersion.version("6.6")) >= 0) { + if (options.getRelease().isPresent()) { + specs.setRelease(options.getRelease().get()); + return specs; + } + } + if (argsSourceCompatibility.isEmpty() && specs.getSourceCompatibility() == null) { + String sourceCompatibility = javaCompile.getSourceCompatibility(); + if (sourceCompatibility != null) { + specs.setSourceCompatibility(sourceCompatibility); + } + } + if (argsTargetCompatibility.isEmpty() && specs.getTargetCompatibility() == null) { + String targetCompatibility = javaCompile.getTargetCompatibility(); + if (targetCompatibility != null) { + specs.setTargetCompatibility(targetCompatibility); + } + } + return specs; + } + + /** + * Get the source compatibility level of the build variant. + */ + private static String getSourceCompatibility(List compilerArgs) { + return findFirstCompilerArgMatch(compilerArgs, + Stream.of("-source", "--source", "--release")) + .orElse(""); + } + + /** + * Get the target compatibility level of the build variant. + */ + private static String getTargetCompatibility(List compilerArgs) { + return findFirstCompilerArgMatch(compilerArgs, + Stream.of("-target", "--target", "--release")) + .orElse(""); + } + + private static Optional findCompilerArg(List compilerArgs, String arg) { + int idx = compilerArgs.indexOf(arg); + if (idx >= 0 && idx < compilerArgs.size() - 1) { + return Optional.of(compilerArgs.get(idx + 1)); + } + return Optional.empty(); + } + + private static Optional findFirstCompilerArgMatch(List compilerArgs, + Stream args) { + return args.map(arg -> findCompilerArg(compilerArgs, arg)) + .filter(Optional::isPresent) + .map(Optional::get) + .findFirst(); + } + // endregion + } diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java index 2bd7d7f6..d425b516 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/SourceSetUtils.java @@ -1,5 +1,13 @@ package com.microsoft.java.bs.gradle.plugin.utils; +import com.microsoft.java.bs.gradle.model.SupportedLanguages; +import com.microsoft.java.bs.gradle.plugin.JavaLanguageModelBuilder; +import com.microsoft.java.bs.gradle.plugin.LanguageModelBuilder; +import com.microsoft.java.bs.gradle.plugin.ScalaLanguageModelBuilder; + +import java.util.LinkedList; +import java.util.List; + /** * Utility class for common source set operations. */ @@ -41,4 +49,30 @@ public static String getFullTaskName(String modulePath, String taskName) { return modulePath + ":" + taskName; } + /** + * Returns a list of LanguageModelBuilder for the supported languages. + */ + public static List getSupportedLanguageModelBuilders() { + List results = new LinkedList<>(); + for (String language : getSupportedLanguages()) { + if (language.equalsIgnoreCase(SupportedLanguages.JAVA.getBspName())) { + results.add(new JavaLanguageModelBuilder()); + } else if (language.equalsIgnoreCase(SupportedLanguages.SCALA.getBspName())) { + results.add(new ScalaLanguageModelBuilder()); + } + } + return results; + } + + /** + * Returns a list of bsp names for the supported languages. + */ + public static String[] getSupportedLanguages() { + String supportedLanguagesProps = System.getProperty("bsp.gradle.supportedLanguages"); + if (supportedLanguagesProps != null) { + return supportedLanguagesProps.split(","); + } + return new String[]{}; + } + } From f129e626874179194621bca70bd645af966d2fb2 Mon Sep 17 00:00:00 2001 From: Tanish Ranjan <62828604+Tanish-Ranjan@users.noreply.github.com> Date: Sun, 1 Sep 2024 11:24:56 +0530 Subject: [PATCH 15/15] Addressing comments. --- .../java/bs/gradle/plugin/utils/AndroidUtils.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java index a7e70739..c551b592 100644 --- a/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java +++ b/plugin/src/main/java/com/microsoft/java/bs/gradle/plugin/utils/AndroidUtils.java @@ -18,7 +18,6 @@ import org.gradle.api.provider.Provider; import org.gradle.api.tasks.compile.CompileOptions; import org.gradle.api.tasks.compile.JavaCompile; -import org.gradle.plugins.ide.internal.tooling.java.DefaultInstalledJdk; import org.gradle.util.GradleVersion; import java.io.File; @@ -285,14 +284,6 @@ private static GradleSourceSet convertVariantToGradleSourceSet(Project project, if (isJavaSupported) { DefaultJavaExtension extension = new DefaultJavaExtension(); - extension.setJavaHome(DefaultInstalledJdk.current().getJavaHome()); - extension.setJavaVersion(DefaultInstalledJdk.current().getJavaVersion().getMajorVersion()); - - extension.setSourceDirs(sourceDirs); - extension.setGeneratedSourceDirs(generatedSources); - extension.setClassesDir(sourceOutputs.iterator().next()); - extension.setCompileTaskName(compileTaskName); - extension.setCompilerArgs(compilerArgs); extension.setSourceCompatibility(getSourceCompatibility(compilerArgs)); extension.setTargetCompatibility(getTargetCompatibility(compilerArgs));