Linux uses nexus3.x to build Android

Source: Internet
Author: User

Reprint Please specify source: http://blog.csdn.net/smartbetter/article/details/55116889

Now Android Studio uses Gradle as a dependency management tool,
It can be said that Android is currently the best rely on management tools, we often through the build.gradle through a simple dependency configuration can use an open source project, such as Okhttp, retrofit, But if the company's core library to Jcenter upload is not likely, based on this issue, today brings you this article, on the powerful Linux platform, using nexus3.x for Android to build their own local internal warehouse.

1. Warehouse Management Tools nexus3.x Introduction

Nexus is an "out-of-the-box" system that does not require a database, it uses the file system plus lucene to organize data, and supports WebDAV and LDAP security identity authentication. Nexus also provides a powerful warehouse management function, component search functionality, which is based on rest, and the friendly UI is a ExtJS rest client that consumes less memory and is based on a simple file system rather than a database.

Nexus greatly simplifies the maintenance of local internal warehouses and access to external warehouses. In addition, the Nexus can also maintain local warehouses while acting on remote warehouses, reducing the load on the central warehouse and saving the bandwidth and time of the external network.

This nexus chooses the 3.x version, and the nexus3.x has changed a lot compared to the 2.x version:

1)从底层重构,从而提高性能,增强扩展能力,并改善用户体验2)升级界面,增加更多的浏览,搜索和管理功能3)提供安装包,使部署更简单(安装完自动添加成服务,省去手动添加的麻烦)4)增加 Docker,NuGet,npm,Bower的支持5)提供新的管理接口,从而能自动管理任务。注意:3.x版本只能运行在JVM8及以上

In summary, the advantages of local internal warehouses in building a local nexus are:

1)加速构建、稳定;2)节省带宽、节省中央maven仓库的带宽;3)控制和审计;4)能够部署第三方构件;5)可以建立本地内部仓库、可以建立公共仓库

These advantages make the Nexus increasingly the most popular MAVEN warehouse manager.

2.Linux platform Remote Shell installation Nexus

Here Linux chooses CentOS7.2.

1) Install JDK reference article HTTP://BLOG.CSDN.NET/SMARTBETTER/ARTICLE/DETAILS/53535435#T3

2) Download Nexus Open source version Https://www.sonatype.com/download-oss-sonatype

3) Upload Server Nexus installation package, server IP assumed to be 192.168.2.20

$ scp ~/Downloads/nexus-3.2.0-01-unix.tar.gz [email protected]:/usr/local

4) Install Nexus (source installation mode)

$ ssh [email protected]                         //SSH连接# cd /usr/local# mkdir nexus# tar -zxvf nexus-3.2.0-01-unix.tar.gz -C nexus //解压缩

After decompression there will be two folders, nexus-3.2.0-01 and Sonatype-work

# cd nexus# mv nexus-3.2.0-01/ nexus

Custom configuration virtual machines can be configured to open the Nexus.vmoptions file (if the Linux hardware configuration is low, it is recommended to modify to the appropriate size, otherwise a run crash will occur):

# cd nexus/bin/nexus.vmoptions                  //虚拟机选项配置文件

4) Start Nexus (default port is 8081)

Some of the commands commonly used by Nexus include:/usr/local/nexus/nexus/bin/nexus {start|stop|run|run-redirect|status|restart|force-reload}, Below we start the Nexus:

# /usr/local/nexus/nexus/bin/nexus start       //启动后稍等会儿才能正常访问WARNING: ************************************************************WARNING: Detected execution as "root" user.  This is NOT recommended!WARNING: ************************************************************Starting nexus

The above warning appears during startup: "Root user startup is not recommended." This warning does not affect the normal access and use of the nexus. Remove the above warning of the method please own Baidu.

Use the following computer to access the Linux server: 192.168.2.20:8081

The page above shows that the configuration Nexus is successful!

3. Create your own Android code repository

Click Nexus "Log in",
Enter the default user name (Admin) and default password (admin123) login.

You can click on the "Settings" icon above, in the "Settings" can add users, roles, docking LDAP settings, such as:

Here we create user users:

After creation, exit admin and log in to user.

We click Repository under repositories to create the Android user's warehouse:

Then fill in the relevant information here, create the warehouse Android:

Let's take a look at the warehouse created:

To this our own warehouse was created successfully.

4. Uploading and referencing the compiled module

Here we use Android Studio to create a new Android Project, then create a new Android Library (module), named Utilslibrary, and create a new Utils class in it for our follow-up testing.

This module is the module we are going to upload.

1. Upload module:

1) Configure Build.gradle for project:

allprojects {    repositories {        jcenter()        mavenLocal()    }}

2) Configure the Build.gradle file for the Android library to be uploaded:

apply plugin:  ' com.android.library '  Apply plugin:  ' maven '  android { ... } uploadarchives {repositories.mavendeployer {repository (url:) {authentication (Username:" user ", Password: "user" )}//With Com.android.support:appcompat-v7:25.1.0  for contrast pom.version= "0.0.1" //corresponding version number 25.1  .0  pom.artifactid= " Utilslibrary "//corresponding appcompat-v7 pom.groupid=" Net.smartbetter "//Com.andro Id.support}}dependencies {} 

The path address is as follows copy:

3) Upload module by double-clicking uploadarchives (such as middle button):

Wait for the module to upload:

When the upload is successful when all OK is displayed, we open the http://192.168.2.20:8081/on the computer, log in to the user, and then look at the previously created warehouse:

OK, to this module upload success.

2. Refer to the module that has been uploaded:

We will then create a new Android project in Android Studio and then configure the project's Build.gradle file:

buildscript {    ...}allprojects {    repositories {        jcenter()        "http://192.168.2.20:8081/repository/android/" }    }}

The path address is as follows copy:

At this point we can refer to the uploaded module in a way that relies on it:

We add dependencies directly in Build.gradle (Module:app):

‘net.smartbetter:utilslibrary:0.0.1‘

Let's take a look at external Libraries:

Discovering that there are already utilslibrary-0.0.1, then we can call utilslibrary-0.0.1 's method in our project.

The above is how to upload our module from Android Studio and how to rely on using the uploaded module.

Like this article remember "top" a bit Oh!

Linux uses nexus3.x to build Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.