Skip to content

Commit 12df250

Browse files
committed
feat: aarIgnoreFilter, jarIgnoreFilter and nsConfig.android.plugins support (for now to add suffix to generated aar using aarSuffix on a per plugin bases)
1 parent 8520174 commit 12df250

9 files changed

Lines changed: 34 additions & 11 deletions

File tree

lib/commands/plugin/build-plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@ export class BuildPluginCommand implements ICommand {
5252
const tempAndroidProject = await this.$tempService.mkdirSync(
5353
"android-project"
5454
);
55-
const gradleArgs = (this.$projectData.nsConfig.android.gradleArgs || [].concat(this.$options.gradleArgs || []));
55+
const gradleArgs = (this.$projectData.nsConfig.android.gradleArgs || []).concat(this.$options.gradleArgs || []);
56+
const pluginOptions = (this.$projectData.nsConfig.android.plugins || {})[pluginName] || {};
5657
const options: IPluginBuildOptions = {
5758
gradlePath: this.$options.gradlePath,
5859
gradleArgs,
5960
aarOutputDir: platformsAndroidPath,
6061
platformsAndroidDirPath: platformsAndroidPath,
6162
pluginName: pluginName,
6263
tempPluginDirPath: tempAndroidProject,
64+
...pluginOptions
6365
};
6466

6567
const androidPluginBuildResult = await this.$androidPluginBuildService.buildAar(

lib/definitions/android-plugin-migrator.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface IAndroidBuildOptions {
1212
tempPluginDirPath: string;
1313
gradleArgs?: string[];
1414
gradlePath?: string;
15+
aarSuffix?: string;
1516
}
1617

1718
interface IAndroidPluginBuildService {

lib/definitions/project.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ interface INsConfigAndroid extends INsConfigPlaform {
147147

148148
gradleArgs?: string[];
149149

150+
plugins?:{ [k:string]: { aarSuffix?: string } }
151+
150152
runtimePackageName?: string
151153
}
152154

lib/services/android-plugin-build-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
193193
const androidSourceDirectories = this.getAndroidSourceDirectories(
194194
options.platformsAndroidDirPath
195195
);
196-
const shortPluginName = getShortPluginName(options.pluginName);
196+
const shortPluginName = getShortPluginName(options.pluginName + (options.aarSuffix || ''));
197197
const pluginTempDir = path.join(options.tempPluginDirPath, shortPluginName);
198198
const pluginSourceFileHashesInfo = await this.getSourceFilesHashes(
199199
options.platformsAndroidDirPath,
@@ -228,7 +228,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
228228
options.projectDir,
229229
options.pluginName
230230
);
231-
const gradleArgs = (this.$projectData.nsConfig.android.gradleArgs || [].concat(options.gradleArgs || []));
231+
const gradleArgs = (this.$projectData.nsConfig.android.gradleArgs || []).concat(options.gradleArgs || []);
232232
await this.buildPlugin({
233233
gradlePath: options.gradlePath,
234234
gradleArgs,

lib/services/android-project-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
758758
AndroidProjectService.ANDROID_PLATFORM_NAME
759759
);
760760
if (this.$fs.exists(pluginPlatformsFolderPath)) {
761-
const gradleArgs = (projectData.nsConfig.android.gradleArgs || [].concat(this.$options.gradleArgs || []));
761+
const gradleArgs = (projectData.nsConfig.android.gradleArgs || []).concat(this.$options.gradleArgs || []);
762+
const pluginOptions = (projectData.nsConfig.android.plugins || {})[pluginData.name] || {};
762763
const options: IPluginBuildOptions = {
763764
gradlePath: this.$options.gradlePath,
764765
gradleArgs,
@@ -767,6 +768,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
767768
platformsAndroidDirPath: pluginPlatformsFolderPath,
768769
aarOutputDir: pluginPlatformsFolderPath,
769770
tempPluginDirPath: path.join(projectData.platformsDir, "tempPlugin"),
771+
...pluginOptions
770772
};
771773

772774
if (await this.$androidPluginBuildService.buildAar(options)) {

lib/services/android/gradle-build-args-service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ export class GradleBuildArgsService implements IGradleBuildArgsService {
6969
`-PappPath=${this.$projectData.getAppDirectoryPath()}`,
7070
`-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`
7171
);
72-
if (buildData.gradleArgs) {
72+
const gradleArgs = (this.$projectData.nsConfig.android.gradleArgs || []).concat(buildData.gradleArgs || []);
73+
if (gradleArgs) {
7374
const additionalArgs: string[] = [];
74-
buildData.gradleArgs.forEach((arg) => {
75+
gradleArgs.forEach((arg) => {
7576
additionalArgs.push(...arg.split(" ").map((a) => a.trim()));
7677
});
7778
args.push(...additionalArgs);

lib/services/plugins-service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ export class PluginsService implements IPluginsService {
255255
const currentPluginNativeHashes = await this.getPluginNativeHashes(
256256
pluginPlatformsFolderPath
257257
);
258-
259258
if (
260259
!oldPluginNativeHashes ||
261260
this.$filesHashService.hasChangesInShasums(

vendor/gradle-app/app/build.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,23 @@ dependencies {
401401

402402
task addDependenciesFromNativeScriptPlugins {
403403
nativescriptDependencies.each { dep ->
404-
def aarFiles = fileTree(dir: file("$rootDir/${dep.directory}/$PLATFORMS_ANDROID"), include: ["**/*.aar"])
404+
def aarFiles = fileTree(dir: file("$rootDir/${dep.directory}/$PLATFORMS_ANDROID")).matching {
405+
include "**/*.aar"
406+
exclude "cpp/**"
407+
exclude project.hasProperty("aarIgnoreFilter") ? project.findProperty('aarIgnoreFilter').split(',').collect{it as String} : []
408+
}
405409
aarFiles.each { aarFile ->
406410
def length = aarFile.name.length() - 4
407411
def fileName = aarFile.name[0..<length]
408412
outLogger.withStyle(Style.SuccessHeader).println "\t + adding aar plugin dependency: " + aarFile.getAbsolutePath()
409413
project.dependencies.add("implementation", [name: fileName, ext: "aar"])
410414
}
411415

412-
def jarFiles = fileTree(dir: file("$rootDir/${dep.directory}/$PLATFORMS_ANDROID"), include: ["**/*.jar"])
416+
def jarFiles = fileTree(dir: file("$rootDir/${dep.directory}/$PLATFORMS_ANDROID")).matching {
417+
include "**/*.jar"
418+
exclude "cpp/**"
419+
exclude project.hasProperty("jarIgnoreFilter") ? project.findProperty('jarIgnoreFilter').split(',').collect{it as String} : []
420+
}
413421
jarFiles.each { jarFile ->
414422
def jarFileAbsolutePath = jarFile.getAbsolutePath()
415423
outLogger.withStyle(Style.SuccessHeader).println "\t + adding jar plugin dependency: $jarFileAbsolutePath"

vendor/gradle-plugin/build.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,11 @@ android {
317317

318318
task addDependenciesFromNativeScriptPlugins {
319319
nativescriptDependencies.each { dep ->
320-
def aarFiles = fileTree(dir: getDepPlatformDir(dep), include: ["**/*.aar"])
320+
def aarFiles = fileTree(dir: getDepPlatformDir(dep)).matching {
321+
include "**/*.aar"
322+
exclude "cpp/**"
323+
exclude project.hasProperty("aarIgnoreFilter") ? project.findProperty('aarIgnoreFilter').split(',').collect{it as String} : []
324+
}
321325
def currentDirname = file(project.buildscript.sourceFile).getParentFile().getName()
322326
aarFiles.each { aarFile ->
323327
def length = aarFile.name.length() - 4
@@ -329,7 +333,11 @@ task addDependenciesFromNativeScriptPlugins {
329333
project.dependencies.add("implementation", [name: fileName, ext: "aar"])
330334
}
331335

332-
def jarFiles = fileTree(dir: getDepPlatformDir(dep), include: ["*.jar"])
336+
def jarFiles = fileTree(dir: getDepPlatformDir(dep)).matching {
337+
include "**/*.jar"
338+
exclude "cpp/**"
339+
exclude project.hasProperty("jarIgnoreFilter") ? project.findProperty('jarIgnoreFilter').split(',').collect{it as String} : []
340+
}
333341
jarFiles.each { jarFile ->
334342
def jarFileAbsolutePath = jarFile.getAbsolutePath()
335343
outLogger.withStyle(Style.SuccessHeader).println "\t + adding jar plugin dependency: $jarFileAbsolutePath"

0 commit comments

Comments
 (0)