@@ -24,6 +24,7 @@ describe("androidPluginBuildService", () => {
2424 const pluginName = "my-plugin" ;
2525 const shortPluginName = getShortPluginName ( pluginName ) ;
2626 let spawnFromEventCalled = false ;
27+ let builtPluginDirName : string = null ;
2728 let fs : IFileSystem ;
2829 let androidBuildPluginService : AndroidPluginBuildService ;
2930 let tempFolder : string ;
@@ -46,6 +47,7 @@ describe("androidPluginBuildService", () => {
4647 } ) : IPluginBuildOptions {
4748 options = options || { } ;
4849 spawnFromEventCalled = false ;
50+ builtPluginDirName = null ;
4951 tempFolder = mkdtempSync (
5052 path . join ( tmpdir ( ) , "androidPluginBuildService-temp-" ) ,
5153 ) ;
@@ -75,11 +77,16 @@ describe("androidPluginBuildService", () => {
7577 const testInjector : IInjector = new stubs . InjectorStub ( ) ;
7678 testInjector . register ( "fs" , FsLib . FileSystem ) ;
7779 testInjector . register ( "childProcess" , {
78- spawnFromEvent : async ( command : string ) : Promise < ISpawnResult > => {
79- const finalAarName = `${ shortPluginName } -release.aar` ;
80+ spawnFromEvent : async (
81+ command : string ,
82+ args : string [ ] ,
83+ ) : Promise < ISpawnResult > => {
84+ // the plugin dir gradle was pointed at is what names the built aar
85+ const pluginDir = args [ args . indexOf ( "-p" ) + 1 ] ;
86+ builtPluginDirName = path . basename ( pluginDir ) ;
87+ const finalAarName = `${ builtPluginDirName } -release.aar` ;
8088 const aar = path . join (
81- tempFolder ,
82- shortPluginName ,
89+ pluginDir ,
8390 "build" ,
8491 "outputs" ,
8592 "aar" ,
@@ -269,6 +276,28 @@ dependencies {
269276 assert . isTrue ( spawnFromEventCalled ) ;
270277 } ) ;
271278
279+ it ( "builds an aar named after the plugin" , async ( ) => {
280+ const config : IPluginBuildOptions = setup ( { addManifest : true } ) ;
281+
282+ await androidBuildPluginService . buildAar ( config ) ;
283+
284+ assert . deepStrictEqual ( builtPluginDirName , shortPluginName ) ;
285+ assert . isTrue (
286+ fs . exists ( path . join ( pluginFolder , `${ shortPluginName } .aar` ) ) ,
287+ ) ;
288+ } ) ;
289+
290+ it ( "appends aarSuffix to the name of the built aar" , async ( ) => {
291+ const config : IPluginBuildOptions = setup ( { addManifest : true } ) ;
292+ config . aarSuffix = "-v2" ;
293+
294+ await androidBuildPluginService . buildAar ( config ) ;
295+
296+ const expectedName = getShortPluginName ( `${ pluginName } -v2` ) ;
297+ assert . deepStrictEqual ( builtPluginDirName , expectedName ) ;
298+ assert . isTrue ( fs . exists ( path . join ( pluginFolder , `${ expectedName } .aar` ) ) ) ;
299+ } ) ;
300+
272301 it ( "does not build aar when there are no supported files in the plugin" , async ( ) => {
273302 const config : IPluginBuildOptions = setup ( ) ;
274303
0 commit comments