Create BitBucket's private maven repository and upload aar to BitBucket's maven repository
Reprint please mark the original address: http://blog.csdn.net/lsyz0021/article/details/52065404
When we use the development of Android studio, we can use the compile "" command very conveniently to use someone else's third-party AAR library
For example, when we quote okhttp, we can do it in Gradle:
dependencies { compile ' com.squareup.okhttp3:okhttp:3.3.1 '}
Feel good tall on, today we come to realize their library in gradle with compile reference, to BitBucket warehouse for example, of course, GitHub can also, here do not talk, read this article can try GitHub.
1, first we create a project, which contains a
toolslibrary library and an
app module, so that the app relies on toolslibrary.
App Dependency Toolslibrary
We wrote a Toast tool class in toolslibrary to test the effect, and then call it in the app.
2, if your local no SSH key needs to be configured first, otherwise it will fail, configure the way please refer to this blog:
Steps to create a key under Git SSH under Windows 7: http://blog.csdn.net/lsyz0021/article/details/52064829
3. To create the BitBucket maven Warehouse, we aim at this step:
(1) Create a MAVEN repository,
(2) Main branch is release
(3) Upload a "readme.md" document to the repository
You do not have to use the following steps, you can use your own way, but you must meet the above three conditions, otherwise it will fail.
3.1. We create a bitbucket_maven warehouse in BitBucket
3.2, clone to local, hint is an empty warehouse
3.3. Enter the Bitbucket_maven folder
CD Bitbucket_maven
3.4, create a new MD file, the content is casually written, named "Readme.md", must be the name or will fail. Copy to the Bitbucket_maven folder ,
Then git adds the readme.md file
git add readme.md
3.5, Commit, this step is more troublesome, if you have used Linux under the VI or VIM will feel very simple
Git commit
After entering the command, you may enter an interface that you will not be able to manipulate, but don't worry, take a closer look at this passage.
1, first you press enter or "I" to enter the editing state,
2, then use the keyboard arrow keys to move the cursor to the bottom, casually enter the letter, I enter Init here,
3, press "ESC" key, then hold "shift" + " colon " key (l key to the right), you will find that there is a ":" In the lower left,
4, then enter "w", "Q" Two letters, indicating the meaning of saving exit.
No, look closely.
3.6. Create a new release branch
GIT branch releases
3.7. Push to Warehouse
Git Push Origin releases
3.8, enter the BitBucket can see our uploaded readme.md file
3.9, if you are other ways to complete this step, you must ensure that the main branch is release, here we can view settings
4. Realization function
We used the Gitasmaven tool Https://github.com/lsyz0021/GitAsMaven
You can either add the following command to the Build.gradle in your toolslibrary, or you can copy the file directly to the toolslibrary root and reference it, the latter I chose.
from 'https://raw.githubusercontent.com/JeroenMols/GitAsMaven/master/publish-bitbucket.gradle'
4.1, direct clone down to copy the Publish-bitbucket.gradle file to the toolslibrary root directory , build.gradle reference him
from ' Publish-bitbucket.gradle '
4.2, create the Gradle.properties file in the root directory of toolslibrary , copy the following file, paste save. This step must be careful, otherwise it is easy to fail,
Note: There must be no spaces after the equals sign
<pre name= "code" class= "Java" >ARTIFACT_PACKAGE=< package name >
Artifact_name=<librar name >
artifact_version=< version number >ARTIFACT_PACKAGING=aarCOMPANY=< account name/group name >REPOSITORY_NAME=< warehouse name >
My configuration
4.3. Copy the following configuration into your project's gradle.properties file
Username=<bitbucket account >password=<bitbucket Password >
5, the last step, execute the Run command
Enter the following command in terminal and then enter to start execution ( before the first execution of the command, be sure to Rebuildproject first)
Gradlew uploadarchives
Lucky to be successful once.
6. Summary of Issues
6.1, look at the results, although the hint 401 but still no problem, the error is because it does not support Chinese javadoc, I will give a solution after
To resolve the "encoding GBK non-mapped characters" error, we modify the following in Publish-bitbucket.gradle
Then re-execute the command (note: The version number (artifact_version=1.0.1) must be modified to execute again, or it will fail)
Gradlew uploadarchives
You can see that the 1.0.1 version upload was successful, and there is no "error encoding GBK characters"
BitBucket Warehouse Files
6.2. If you fail to upload your library, you can try this method.
7, test the results of the reference
Here I've created a new project and configured three places to go.
7.1. Set up your account and password
7.2. Set the dependent address and configure it in the Build.gradle of your new project
Maven { url "https://api.bitbucket.org/1.0/repositories/<code class=" Objectivec "><span class=" Hljs-string "></span></code> user name or team name/warehouse name/raw/releases" credentials { username username Password Password } }
7.3, the reference to rely on, the most critical one
Reference format
Compile ' ARTIFACT_PACKAGE:ARTIFACT_NAME:ARTIFACT_VERSION '//This is the format of the reference
7.4, call Toastutils this class
You can see that you can call it, that means it's successful.
Reference article: http://www.jianshu.com/p/72996bc89b7c#
Reference article: Http://jeroenmols.com/blog/2016/02/05/wagongit/?utm_source=tuicool&utm_medium=referral
Create BitBucket's private maven repository and upload aar to BitBucket's Maven warehouse (by Star Wuge)