Skip to content

Commit 6e3650a

Browse files
committed
refactor: rebuild aar files in nodemodules if necessary
handle --syncAllFiles in node_modules pass the same gradle options to the buildAar plugin and the native project
1 parent 069e69f commit 6e3650a

21 files changed

+962
-70
lines changed

lib/bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ $injector.require("projectData", "./project-data");
99
$injector.requirePublic("projectDataService", "./services/project-data-service");
1010
$injector.requirePublic("projectService", "./services/project-service");
1111
$injector.require("androidProjectService", "./services/android-project-service");
12+
$injector.require("androidPluginBuildService", "./services/android-plugin-build-service");
1213
$injector.require("iOSEntitlementsService", "./services/ios-entitlements-service");
1314
$injector.require("iOSProjectService", "./services/ios-project-service");
1415
$injector.require("iOSProvisionService", "./services/ios-provision-service");

lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const RESOURCES_DIR = "res";
3131
export const CONFIG_NS_FILE_NAME = "nsconfig.json";
3232
export const CONFIG_NS_APP_RESOURCES_ENTRY = "appResourcesPath";
3333
export const CONFIG_NS_APP_ENTRY = "appPath";
34+
export const DEPENDENCIES_JSON_NAME = "dependencies.json";
3435

3536
export class PackageVersion {
3637
static NEXT = "next";
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
interface IBuildOptions {
3+
platformsAndroidDirPath: string,
4+
pluginName: string,
5+
aarOutputDir: string,
6+
tempPluginDirPath: string,
7+
platformData: IPlatformData //don't make optional! (makes sure the plugins are built with the same parameters as the project),
8+
}
9+
10+
interface IAndroidPluginBuildService {
11+
buildAar(options: IBuildOptions): Promise<boolean>;
12+
migrateIncludeGradle(options: IBuildOptions): void;
13+
}

lib/definitions/project.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,26 @@ interface IPlatformProjectService extends NodeJS.EventEmitter {
297297
* If there are parts in the project that are inconsistent with the desired options, marks them in the changeset flags.
298298
*/
299299
checkForChanges(changeset: IProjectChangesInfo, options: IProjectChangesOptions, projectData: IProjectData): Promise<void>;
300+
301+
/**
302+
* Build native part of a nativescript plugins if necessary
303+
*/
304+
prebuildNativePlugin(buildOptions: IBuildOptions): Promise<void>;
305+
306+
/**
307+
* Traverse through the production dependencies and find plugins that need build/rebuild
308+
*/
309+
checkIfPluginsNeedBuild(projectData: IProjectData): Promise<Array<any>>;
310+
311+
/**
312+
* Get gradle options the CLI generates when building project
313+
*/
314+
getBuildOptions(configurationFilePath?: string): Array<string>;
315+
316+
/**
317+
* Get gradle options the CLI generates when building project
318+
*/
319+
executeCommand(projectRoot: string, args: any, childProcessOpts?: any, spawnFromEventOptions?: ISpawnFromEventOptions): Promise<ISpawnResult>;
300320
}
301321

302322
interface IAndroidProjectPropertiesManager {

lib/project-data.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ export class ProjectData implements IProjectData {
152152
}
153153

154154
private getNsConfigContent(projectDir: string): string {
155+
if (!projectDir) {
156+
return null;
157+
}
158+
155159
const configNSFilePath = path.join(projectDir, constants.CONFIG_NS_FILE_NAME);
156160

157161
if (!this.$fs.exists(configNSFilePath)) {

0 commit comments

Comments
 (0)