diff --git a/packages/core/jsonSchema/renative-1.0.schema.json b/packages/core/jsonSchema/renative-1.0.schema.json index fb42f1685..fe487b08a 100644 --- a/packages/core/jsonSchema/renative-1.0.schema.json +++ b/packages/core/jsonSchema/renative-1.0.schema.json @@ -710,7 +710,6 @@ } } }, - "required": ["repositories", "dependencies", "ext", "custom"], "additionalProperties": false }, "injectAfterAll": { diff --git a/packages/core/jsonSchema/rnv.app.json b/packages/core/jsonSchema/rnv.app.json index dd6ff2ffa..a40e6cac3 100644 --- a/packages/core/jsonSchema/rnv.app.json +++ b/packages/core/jsonSchema/rnv.app.json @@ -537,12 +537,6 @@ } } }, - "required": [ - "repositories", - "dependencies", - "ext", - "custom" - ], "additionalProperties": false }, "injectAfterAll": { diff --git a/packages/core/jsonSchema/rnv.plugin.json b/packages/core/jsonSchema/rnv.plugin.json index a8e2981f5..ba660078a 100644 --- a/packages/core/jsonSchema/rnv.plugin.json +++ b/packages/core/jsonSchema/rnv.plugin.json @@ -237,7 +237,6 @@ } } }, - "required": ["repositories", "dependencies", "ext", "custom"], "additionalProperties": false }, "injectAfterAll": { diff --git a/packages/core/jsonSchema/rnv.project.json b/packages/core/jsonSchema/rnv.project.json index 90d8e6780..3d97c5d22 100644 --- a/packages/core/jsonSchema/rnv.project.json +++ b/packages/core/jsonSchema/rnv.project.json @@ -860,12 +860,6 @@ } } }, - "required": [ - "repositories", - "dependencies", - "ext", - "custom" - ], "additionalProperties": false }, "injectAfterAll": { diff --git a/packages/core/jsonSchema/rnv.templates.json b/packages/core/jsonSchema/rnv.templates.json index c5490445a..78b185ed0 100644 --- a/packages/core/jsonSchema/rnv.templates.json +++ b/packages/core/jsonSchema/rnv.templates.json @@ -331,12 +331,6 @@ } } }, - "required": [ - "repositories", - "dependencies", - "ext", - "custom" - ], "additionalProperties": false }, "injectAfterAll": { diff --git a/packages/core/src/schema/platforms/fragments/templateAndroid.ts b/packages/core/src/schema/platforms/fragments/templateAndroid.ts index e97d2df8b..2a5ccfeac 100644 --- a/packages/core/src/schema/platforms/fragments/templateAndroid.ts +++ b/packages/core/src/schema/platforms/fragments/templateAndroid.ts @@ -127,12 +127,14 @@ const templateAndroid = z build_gradle: z .object({ plugins: z.array(z.string()), - buildscript: z.object({ - repositories: z.array(z.string()), - dependencies: z.array(z.string()), - ext: z.array(z.string()), - custom: z.array(z.string()), - }), + buildscript: z + .object({ + repositories: z.array(z.string()), + dependencies: z.array(z.string()), + ext: z.array(z.string()), + custom: z.array(z.string()), + }) + .partial(), injectAfterAll: z.array(z.string()), }) .partial() diff --git a/packages/engine-rn-tvos/templates/platforms/androidtv/app/build.gradle b/packages/engine-rn-tvos/templates/platforms/androidtv/app/build.gradle index fb4729d6b..40d89b2c0 100644 --- a/packages/engine-rn-tvos/templates/platforms/androidtv/app/build.gradle +++ b/packages/engine-rn-tvos/templates/platforms/androidtv/app/build.gradle @@ -1,6 +1,7 @@ apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" +{{PLUGIN_APPLY}} {{PLUGIN_LOCAL_PROPERTIES}} diff --git a/packages/engine-rn-tvos/templates/platforms/firetv/app/build.gradle b/packages/engine-rn-tvos/templates/platforms/firetv/app/build.gradle index 580422d43..de72e2822 100644 --- a/packages/engine-rn-tvos/templates/platforms/firetv/app/build.gradle +++ b/packages/engine-rn-tvos/templates/platforms/firetv/app/build.gradle @@ -1,6 +1,7 @@ apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" +{{PLUGIN_APPLY}} {{PLUGIN_LOCAL_PROPERTIES}} diff --git a/packages/engine-rn/templates/platforms/android/app/build.gradle b/packages/engine-rn/templates/platforms/android/app/build.gradle index b6bd8e47c..e1107967c 100644 --- a/packages/engine-rn/templates/platforms/android/app/build.gradle +++ b/packages/engine-rn/templates/platforms/android/app/build.gradle @@ -1,7 +1,7 @@ apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" - +{{PLUGIN_APPLY}} {{PLUGIN_LOCAL_PROPERTIES}} diff --git a/packages/engine-rn/templates/platforms/androidwear/app/build.gradle b/packages/engine-rn/templates/platforms/androidwear/app/build.gradle index f7746badc..bf2386f17 100644 --- a/packages/engine-rn/templates/platforms/androidwear/app/build.gradle +++ b/packages/engine-rn/templates/platforms/androidwear/app/build.gradle @@ -1,6 +1,7 @@ apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" +{{PLUGIN_APPLY}} {{PLUGIN_LOCAL_PROPERTIES}} diff --git a/packages/sdk-android/src/gradleParser.ts b/packages/sdk-android/src/gradleParser.ts index 05c4eb2d9..7845e4eac 100644 --- a/packages/sdk-android/src/gradleParser.ts +++ b/packages/sdk-android/src/gradleParser.ts @@ -21,6 +21,7 @@ import { import path from 'path'; import { getBuildFilePath, getAppId, getAppVersion, getAppVersionCode, addSystemInjects } from '@rnv/sdk-utils'; import { Context, getContext } from './getContext'; +import { TemplateAndroid } from './types'; const currentOs = process.platform === 'darwin' ? 'osx' : process.platform === 'win32' ? 'win64' : 'linux64'; @@ -28,7 +29,6 @@ export const parseBuildGradleSync = () => { const c = getContext(); const appFolder = getAppFolder(); - const templateAndroid = getConfigProp('templateAndroid'); const buildscript = templateAndroid?.build_gradle?.buildscript; @@ -325,6 +325,9 @@ ${chalk().bold.white(c.paths.workspace?.appConfig?.configsPrivate?.join('\n'))}` ${releaseBuildTypes.join('\n ')} }`; + // APP/BUILD.GRADLE + _parseAppBuildGradleObject(appBuildGradle); + // MULTI APK // const versionCodeOffset = getConfigProp('versionCodeOffset', 0); const isMultiApk = getConfigProp('multipleAPKs') === true; @@ -666,36 +669,7 @@ export const parseAndroidConfigObject = (plugin?: ConfigPluginPlatformSchema, ke const templateAndroid = plugin?.templateAndroid; const appBuildGradle = templateAndroid?.app_build_gradle; - if (appBuildGradle) { - if (appBuildGradle.apply) { - appBuildGradle.apply.forEach((v) => { - c.payload.pluginConfigAndroid.applyPlugin += `apply ${sanitizePluginPath(v, key)}\n`; - }); - } - - if (appBuildGradle.defaultConfig) { - appBuildGradle.defaultConfig.forEach((v) => { - c.payload.pluginConfigAndroid.defaultConfig += `${sanitizePluginPath(v, key)}\n`; - }); - } - - const { implementations } = appBuildGradle; - if (implementations) { - implementations.forEach((v) => { - c.payload.pluginConfigAndroid.appBuildGradleImplementations += ` implementation ${sanitizePluginPath( - v, - key - )}\n`; - }); - } - - const afterEvaluate = appBuildGradle?.afterEvaluate; - if (afterEvaluate) { - afterEvaluate.forEach((v) => { - c.payload.pluginConfigAndroid.appBuildGradleAfterEvaluate += ` ${sanitizePluginPath(v, key)}\n`; - }); - } - } + _parseAppBuildGradleObject(appBuildGradle, key); // BUILD.GRADLE const buildGradle = templateAndroid?.build_gradle; @@ -740,6 +714,41 @@ const _fixAndroidLegacy = (c: RnvContext, modulePath: string) => { } }; +const _parseAppBuildGradleObject = (appBuildGradle: TemplateAndroid['app_build_gradle'] | undefined, key = '') => { + const c = getContext(); + if (appBuildGradle) { + if (appBuildGradle.apply) { + appBuildGradle.apply.forEach((v) => { + c.payload.pluginConfigAndroid.applyPlugin += v.includes('apply') + ? `${sanitizePluginPath(v, key)}\n` + : `apply ${sanitizePluginPath(v, key)}\n`; + }); + } + + if (appBuildGradle.defaultConfig) { + appBuildGradle.defaultConfig.forEach((v) => { + c.payload.pluginConfigAndroid.defaultConfig += `${sanitizePluginPath(v, key)}\n`; + }); + } + + const { implementations } = appBuildGradle; + if (implementations) { + implementations.forEach((v) => { + c.payload.pluginConfigAndroid.appBuildGradleImplementations += ` implementation ${sanitizePluginPath( + v, + key + )}\n`; + }); + } + + const afterEvaluate = appBuildGradle?.afterEvaluate; + if (afterEvaluate) { + afterEvaluate.forEach((v) => { + c.payload.pluginConfigAndroid.appBuildGradleAfterEvaluate += ` ${sanitizePluginPath(v, key)}\n`; + }); + } + } +}; // const _getPrivateConfig = (c, platform) => { // let privateConfigFolder = path.join(c.paths.workspace.dir, c.files.project.package.name, c.buildConfig.id); // if (!fsExistsSync(privateConfigFolder)) {