1. Add the following sections to build.gradle under the module chrisbaselibrary that needs to be published
//maven Plug-in unit apply plugin: 'maven' //Pack main Code and resource under directory task task androidSourcesJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } //Configuration needs to be uploaded to maven Warehouse Documents artifacts { archives androidSourcesJar } //Upload to Maven Warehouse task uploadArchives { repositories { mavenDeployer { //Appoint maven Warehouse url If you use a snapshot library, you need to pay attention to the suffix of the version number repository(url: "http://maven.ai-ways.com/nexus/content/repositories/releases/") { //nexus Login default username and password userName Case to match authentication(userName: "admin", password: "Aa1111111") } pom.groupId = 'com.chris' pom.artifactId = 'base-library' pom.version = '1.0.0' } } }
Add it directly to the end.
Use gradle's plug-in upload Archives for deployment.
After successful deployment, we can modify the dependency of the app module. However, it is suggested to build another project for dependency testing. After all, the app module in this project is used for real-time testing, and it does not need to be deployed before synchronization.
Modify the warehouse settings in the project build.gradle file:
allprojects { repositories { maven { url 'http://maven.ai-ways.com/nexus/content/repositories/releases' } google() jcenter() } }
Then add dependencies in build.gradle under module:
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' //implementation project(path: ':chrisbaselibrary') implementation 'com.chris:base-library:1.0.0' }