Recently Xiao Ming is reading a book called Gains and Losses of Economic Changes in the Past Dynasties, which analyzes economic changes from a historical perspective. By studying economic methods, as an engineering graduate, Xiao Ming directly thought of data statistics and establishing mathematical theoretical models, and the way of starting this book became the first attraction. In addition to the familiar historical events, figures and class struggles, what left a deep impression is the game between closed autocracy and open reform. Showing a vibrant ecosystem, Open and Share are good choices. The Pluto framework, “Pluto, my Open Source Android development framework,” was opened on April 27 and received objectively positive feedback. At this point, the second step in this subjective process is to make Pluto easier to use – share Pluto with jCenter as the Library.
1. Article value
1. Implement my Pluto framework and share it with jCenter, so you can use the framework directly with a gradle statement. 2. Follow my implementation steps strictly so that you don’t have to read summaries from other blogs to implement your own library sharing.
dependencies {
compile 'com. Minggo: Pluto: 1.0'
}Copy the code
Among them, bintray.com should be familiar with, should climb the wall? Don’t have to; Gradle is a library Gradle or a Project Gradle. How long does it take to compile and upload? Compilation guarantees no errors on the line, upload is generally 1 minute; How long will the link to jCenter review take? Mine is 3 hours.
2. Bintray Account Settings
1. Overall cognition of the new official website
“View Profile” is the personal center, which will be introduced below to obtain the appKey.”Add New Organization” is to Add an Organization, which is more important. In order to ensure smooth upload, manually configure your own Organization is more appropriate.
2. Add an organization
1) Choose to create a new organization
2) According to the information related to the organization, mainly complete the filling with stars
3) View the created organization page
3. Create a creative library
It is important to manually configure your own warehouse, pay attention to the name of the repository. Because the Pluto repository name will be associated in the Gradle file, the Maven type option is mainly implemented in this article and must be selected. The selection of copyright License is optional, my Pluto project was created on Github with MIT selected, so select MIT. The creation library description is also optional, so I added Pluto’s description on Github.
Under the organization page you can see the warehouse, click to see if you need to know.
4. Get your own ApiKey
Click “Edit Profile” ->”API Key” ->”Show”. You’d better copy it and save it for later gradle configuration.
3. Gradle configuration
1. Three points to pay attention to
In the first place, Project gradle is used to configure maven and Bintray. Library Gradle is used to configure versions, repositories, etc. Third, local.properties is used to configure the Bintray account and apikey. The key content will be in the Library Gradle.
2.Project Gradle is configured with Maven and Bintray plug-ins
Locate the Project Gradle file and add the following lines to your dependencies
dependencies {
//Gradle Android Maven plugin
classpath 'com. Making. Dcendents: android - maven - gradle - plugin: 1.4.1'
//Gradle Bintray Plugin
classpath 'com. Jfrog. Bintray. Gradle: gradle bintray - plugin: 1.7.1'
}Copy the code
Gradle Android Maven Plugin and Gradle Bintray Plugin
3. Configure the account and AppKey for local.properties
Find the local.properties file
bintray.user=minggo620 // Bintray user name
bintray.apikey=ab02158f80eaa139423axxxxxxxxxx //bintray API KEYCopy the code
The apikey copied earlier comes in handy, pasted to the end of the local.properties file. Gitignore files ignore this file upload by default so as not to expose the key.
4.Library Gradle configuration
Go to the Library Gradle file and configure it
#####1) Reference Maven and bintray plugin header plus
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'Copy the code
2) Read the local.properties file
Head attaching
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())Copy the code
3) Configure necessary and optional constants
For example, if the final form is compile ‘com.minggo:Pluto:1.0’, then the group and version are as follows. Pluto is the name of the Library, which is configured in the execution task.
def siteUrl = 'https://github.com/minggo620/Pluto-Android' // Project home page
def gitUrl = 'https://github.com/minggo620/Pluto-Android.git' // Git repository url
version = "1.0"
group = "com.minggo"Copy the code
4) Configure the Bintray matching task
Note that the repo value is the repository name, not the repository type, and the name is the Library name. Only bintray can be written in the license file. UserOrg can be written in bintray to create an organization. The reason for emphasizing this is that I have read other articles and found some misunderstandings.
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
pkg {
repo = 'pluto'// Create your own bintray repository name
name = 'Pluto'/ / the name of the Library
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ['MIT']// It must be the license type selected during warehouse creation
userOrg = 'minggoopen' // The name of the organization created by bintray
publish = true // Whether it is a public project.
version {
name = '1.0'
desc = 'High integrated development framework for Android applications.'
released = new Date()
vcsTag = 'v1.0'
attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
}
}
configurations = ['archives']}Copy the code
5) Configure the Maven Install task
This section is important to generate pom.xml. If you do not have gradlew install, execute the bintrayUpload under Publishing in the Gradle column in Studio.
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'Pluto Android'
description 'High integrated development framework for Android applications.'
url siteUrl
// Set your license
licenses {
license {
name 'MIT'
url 'https://raw.githubusercontent.com/minggo620/Pluto-Android/master/LICENSE'
}
}
developers {
developer {
id 'minggo620' // Enter bintray or Github username
name 'minggo' // The name can be in Chinese
email '[email protected]'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}Copy the code
6) Configure source code and documentation tasks
Remember to add failOnError false in the following response, otherwise install execution occurs and build failed appears.
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
failOnError false // Must be added to avoid errors
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}Copy the code
7) This is the complete cooperation of my Library Gradle
apply plugin: 'com.android.library'
apply plugin: 'android-apt'
apply from: "dependencies.gradle"
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
def siteUrl = 'https://github.com/minggo620/Pluto-Android' // Project home page
def gitUrl = 'https://github.com/minggo620/Pluto-Android.git' // Git repository url
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
version = "1.0"
group = "com.minggo"
android {
compileSdkVersion 23
buildToolsVersion "24.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
consumerProguardFiles 'proguard-rules.pro'
}
buildTypes {
release {
minifyEnabled false
}
}
}
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
pkg {
repo = 'pluto'// Create your own bintray repository name
name = 'Pluto'/ / the name of the Library
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ['MIT']// It must be the license type selected during warehouse creation
userOrg = 'minggoopen' // The name of the organization created by bintray
publish = true // Whether it is a public project.
version {
name = '1.0'
desc = 'High integrated development framework for Android applications.'
released = new Date()
vcsTag = 'v1.0'
attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
}
}
configurations = ['archives']
}
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'Pluto Android'
description 'High integrated development framework for Android applications.'
url siteUrl
// Set your license
licenses {
license {
name 'MIT'
url 'https://raw.githubusercontent.com/minggo620/Pluto-Android/master/LICENSE'
}
}
developers {
developer {
id 'minggo620' // Enter bintray or Github username
name 'minggo' // The name can be in Chinese
email '[email protected]'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}Copy the code
Execute install and upload
The Windows command is different from the MAC command. The MAC command is preceded by a./ retype command. Here is the window implementation.
1. Make sure Gradle is installed
Check the installation status in Terminal in Studio. If not, the installation will be automatic.
gradlew -vCopy the code
The installation is as follows:
2. Run the install task
gradlew installCopy the code
The results are as follows:
:Pluto:bundleRelease UP-TO-DATE
:Pluto:javadoc UP-TO-DATE
:Pluto:javadocJar UP-TO-DATE
:Pluto:sourcesJar UP-TO-DATE
:Pluto:install
BUILD SUCCESSFULCopy the code
3. Execute the upload task
gradlew bintrayUploadCopy the code
After 1 minute, the result is as follows:
:Pluto:install
:Pluto:bintrayUpload
BUILD SUCCESSFUL
Total time: 1 mins 33.999 secs
Copy the code
5. The Link to jCenter
Enter the warehouse management background of Bintray’s Organization to find its corresponding warehouse and find a package as shown in the figure below
All that remains is the mailbox wait. Three hours later…
Vi. Summary of the article
In this way, Puto, my Android development framework, became Library and shared with jCenter. For each subsequent update, only compile ‘com.minggo:Pluto:1.0’ is required for Gradle. It would be cool for developers using the Pluto framework to no longer have to go to Github to download the source code and copy it into their projects. Do you, too, feel the urge to share your Library to JCenter? Gradle configuration and Pluto Framework gitHub github.com/minggo620/P…
[Original production is prohibited from reprinting without authorization]
[Welcome micro friends to share and forward prohibited unauthorized retransmission of public accounts]