How to build Maven's understanding of maven under Android Studio classification of Maven repositories
Local MAVEN warehouse and remote MAVEN repository (central warehouse, third-party warehouse)
Jcenter and Mavencenter
Slightly
Build a maven, download and install the MAVEN environment
Note that you need to modify the settings later
Setting files before 3.0 under C:\USERS\XXX.M2, in fact Androidstudio through the jcenter downloaded jar is placed in this folder. 3.0 after the Conf in the MAVEN directory
Second, download and install the Nexus
After installation, you need to enter the corresponding folder (my nexus-2.11.4-01\bin\jsw\windows-x86-64, different systems in different folders), the first time you need to perform the installation, registered Windows services, open services.
You only need to open the service (Start-nexus.bat) before you can use it.
In the browser, enter: 127.0.0.1:8081/nexus, if the correct response, the installation is successful.
Enter the account name password (default admin/admin123) on the current page
Log in to see that more than 10 warehouses have been built.
Click on Toolbar Add, select Hosted Repository, then fill in the Repository ID, and repository name-> save so you can build a new repository.
We all know that when referencing repository, we need Groupid,artifactid, and the version number. Therefore, a group is required.
Click the toolbar Add, select Repository Group, and then fill in the group ID, and so on.
The system gives us a public group by default, and we can also build several group to manage repository. So we took the public group to include our own group, so that the rest of the team just had to refer to the public group, without having to worry about how the nexus was organized repository.
Be sure to change the settings file, especially but not only do you change the MAVEN storage directory, but you need to add a mirror to Maven to create the Nexus, see below:
<mirrors> <mirror> <!--This sends everything else to /public --> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/nexus/content/groups/public/</url> </mirror></mirrors>
And
<profiles> <profile> <id>nexus</id> <!--Enable snapshots for the built in cent RAL repo to direct-to-<!--all requests to nexus via the mirror--<repositories> <repository> <id>central</id> <url> http://central</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginrepository> ; <id>central</id> <url> http://central</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> < /pluginrepositories> </profile></profiles><!--Activeprofiles | List of profiles that is active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile> Anotheralwaysactiveprofile</activeprofile> </activeProfiles>--><activeprofiles> <!--make The profile active all the--<activeProfile>nexus</activeProfile></activeProfiles>
The original settings file will add a comment at every possible location, explaining what can be changed here. Very humane
Third, package the project and upload to the Nexus
Two different ways:
1. Manual packaging and uploading
Slightly
2, automatic packaging and uploading (of course, including semi-automatic, but also slightly)
Since we are under Android Studio, it is imperative that gradle instead of maven.
Complex Gradle code on the Web, in fact the key steps are only:
1) Reference Maven Plugin
apply plugin: ‘maven‘
And
2)
uploadArchives { repositories.mavenDeployer { repository(url: ‘http://localhost:8081/nexus/content/repositories/wom/‘) {//仓库地址 authentication(userName: "admin",//用户名 password: "admin123")//密码 } pom.project { name ‘chelaile-test-library‘ packaging ‘arr‘ description ‘who are you‘ url ‘http://127.0.0.1:8081/nexus/content/repositories/wom/‘//仓库地址 groupId "try" artifactId ‘chelaileTest‘ version 1.7 } }}
Even
pom.project { name ‘chelaile-test-library‘ packaging ‘arr‘ description ‘who are you‘ url ‘http://127.0.0.1:8081/nexus/content/repositories/wom/‘//仓库地址 groupId "try" artifactId ‘chelaileTest‘ version 1.7 }
Can be used pom.groupId as a substitute.
Iv. use of the library
It's simple, too.
allprojects { repositories { jcenter() maven { url "http://localhost:8081/nexus/content/groups/public/" } }}
Attention
Maven {
URL "http://localhost:8081/nexus/content/groups/public/"
}
Then add the compile statement to the dependency. Note the format here:
Compile ' try:jar-test:2.0 '
Groupid:artifactid: Version number This is the advantage of Gradle build repository, simple commands without lengthy XML format.
Cautionnum 1
When writing gradle, some code will appear gray, the error can not be learned from the source, may be ignored.
Num 2
As ADT supports Jcenter by default, you will never find the jar you want in structrue.
So direct manual input compile ...
Num 3
Problems with introducing libraries
In the jar and AAR format, AAR contains resource files, minifest files, etc., so we need to take care to remove the code that might conflict with the project being introduced.
At the same time, if the uploaded project contains references to other jar packages, other supported jar packages are introduced when the project is referenced.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Build maven under Android Studio