diff --git a/android/README.md b/android/README.md index c2ccc01..cc60b69 100644 --- a/android/README.md +++ b/android/README.md @@ -1,14 +1,29 @@ -README -====== +# Android module -If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: +This library no longer uses Gradle's deprecated **`maven`** plugin or the `installArchives` task. +Artifacts are consumed via **npm** like any other React Native dependency. -1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed -2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK -``` -ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle -sdk.dir=/Users/{username}/Library/Android/sdk +## Tooling + +- Requires **Gradle 7+** and **Android Gradle Plugin (AGP) 7+** (AGP 8 supported). +- The module defines a `namespace` as required by AGP 8. +- Default SDK versions (overrideable from the host app via `rootProject.ext`): + - `compileSdkVersion`: 34 + - `targetSdkVersion`: 34 + - `minSdkVersion`: 21 (projects can raise this to 23+) + +## Publishing to a Maven repository (optional) + +If you still need to publish this module to a Maven repository, migrate to **`maven-publish`**: + +```gradle +apply plugin: 'maven-publish' + +publishing { + publications { + release(MavenPublication) { + from components.release + } + } +} ``` -3. Delete the `maven` folder -4. Run `sudo ./gradlew installArchives` -5. Verify that latest set of generated files is in the maven folder with the correct version number diff --git a/android/build.gradle b/android/build.gradle index 94e9880..cae2936 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,125 +1,41 @@ -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +apply plugin: 'com.android.library' - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath("com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '3.4.1')}") - } +def safeExtGet = { prop, fallback -> + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } -apply plugin: 'com.android.library' -apply plugin: 'maven' - -// Matches values in recent template from React Native (0.59) -// https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L5-L9 -def DEFAULT_COMPILE_SDK_VERSION = 28 -def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3" -def DEFAULT_MIN_SDK_VERSION = 16 -def DEFAULT_TARGET_SDK_VERSION = 28 +def DEFAULT_COMPILE_SDK_VERSION = 34 +def DEFAULT_MIN_SDK_VERSION = 23 +def DEFAULT_TARGET_SDK_VERSION = 34 android { + namespace "com.reactlibrary" compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) - buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) defaultConfig { minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) - versionCode 1 - versionName "1.0" } - lintOptions { + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + lint { abortOnError false } } repositories { - maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native (0.59) - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - url "$projectDir/../node_modules/react-native/android" - } + google() mavenCentral() + // React Native Android artifacts are installed from npm + maven { url "$projectDir/../node_modules/react-native/android" } } dependencies { implementation "com.facebook.react:react-native:${safeExtGet('reactnativeVersion', '+')}" } - -def configureReactNativePom(def pom) { - def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text) - - pom.project { - name packageJson.title - artifactId packageJson.name - version = packageJson.version - group = "com.reactlibrary" - description packageJson.description - url packageJson.repository.baseUrl - - licenses { - license { - name packageJson.license - url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename - distribution 'repo' - } - } - - developers { - developer { - id packageJson.author.username - name packageJson.author.name - } - } - } -} - -afterEvaluate { project -> - - task androidJavadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += files(android.bootClasspath) - classpath += files(project.getConfigurations().getByName('compile').asList()) - include '**/*.java' - } - - task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { - classifier = 'javadoc' - from androidJavadoc.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.srcDirs - include '**/*.java' - } - - android.libraryVariants.all { variant -> - def name = variant.name.capitalize() - task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) { - from variant.javaCompile.destinationDir - } - } - - artifacts { - archives androidSourcesJar - archives androidJavadocJar - } - - task installArchives(type: Upload) { - configuration = configurations.archives - repositories.mavenDeployer { - // Deploy to react-native-event-bridge/maven, ready to publish to npm - repository url: "file://${projectDir}/../android/maven" - - configureReactNativePom pom - } - } -} +// NOTE: legacy 'maven' plugin & custom publishing tasks were removed. +// If publishing from Gradle is still needed, migrate to 'maven-publish' in a follow-up PR. diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 20c90c4..00c8fcc 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,4 +1 @@ - - - + \ No newline at end of file diff --git a/package.json b/package.json index f93eb65..aed11af 100644 --- a/package.json +++ b/package.json @@ -1,43 +1,43 @@ { - "name": "@iconscout/react-native-unicons", - "description": "Unicons - 4,500+ vector icons as easy to use vector React Native Components", - "version": "2.2.0", - "main": "index.js", - "scripts": { - "generate": "node ./build/generate.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Iconscout/react-native-unicons.git", - "baseUrl": "https://github.com/Iconscout/react-native-unicons" - }, - "keywords": [ - "react-native", - "unicons", - "react-native-unicons", - "react-native-icons", - "icons", - "iconscout", - "vector" - ], - "author": { - "name": "IconScout", - "email": "support@iconscout.com" - }, - "license": "IconScout Simple License", - "bugs": { - "url": "https://github.com/Iconscout/react-native-unicons/issues" - }, - "homepage": "https://iconscout.com/unicons", - "peerDependencies": { - "react": ">=16.8.0 <19.0.0", - "react-native": ">=0.57.0-rc.0 <1.0.x", - "react-native-svg": "^9.5.3" - }, - "devDependencies": { - "@iconscout/unicons": "^4.0.7", - "cheerio": "^1.0.0-rc.3", - "fs-plus": "^3.1.1", - "uppercamelcase": "^3.0.0" - } + "name": "@iconscout/react-native-unicons", + "description": "Unicons - 4,500+ vector icons as easy to use vector React Native Components", + "version": "2.2.0", + "main": "index.js", + "scripts": { + "generate": "node ./build/generate.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Iconscout/react-native-unicons.git", + "baseUrl": "https://github.com/Iconscout/react-native-unicons" + }, + "keywords": [ + "react-native", + "unicons", + "react-native-unicons", + "react-native-icons", + "icons", + "iconscout", + "vector" + ], + "author": { + "name": "IconScout", + "email": "support@iconscout.com" + }, + "license": "IconScout Simple License", + "bugs": { + "url": "https://github.com/Iconscout/react-native-unicons/issues" + }, + "homepage": "https://iconscout.com/unicons", + "peerDependencies": { + "react": ">=16.8.0 <20.0.0", + "react-native": ">=0.59.0 <1.0.0", + "react-native-svg": ">=9.5.3 <17.0.0" + }, + "devDependencies": { + "@iconscout/unicons": "^4.0.7", + "cheerio": "^1.0.0-rc.3", + "fs-plus": "^3.1.1", + "uppercamelcase": "^3.0.0" + } }