On the use of Android nexus private server

Let's start with a few words. Since the company's private server has been set up, I don't bother to think about building a private server. I can directly open and upload lib. The following figure shows where I put the component library. Originally, I wanted to pull out a project from one module for maintenance. Later, I thought it was really troublesome. Maintaining multiple libraries at the same time requires down multiple libraries, so I managed them uniformly. Of course, more modules are maintained uniformly, which will naturally affect the compilation speed. You can comment out the modules that are not compiled in settings.gradle. Now there are 7788 libraries such as picture selection, expression, input box, star, video recording and cutting. As for the more component libraries in the back, several projects may be pulled out according to types for management, or version control is also a trouble. At present, it is to upgrade a module and put a tag on GIT. If you have any good suggestions, please leave a message.

Nexus is a community project based on Maven warehouse management. The main use scenario is to build a maven private server on the LAN to deploy third-party public components or as an agent of the remote warehouse on the LAN. To give a few examples:

1. Third party jar packages can be placed on nexus, and projects can be directly referenced through URL and path configuration to facilitate unified management

2. At the same time, when multiple projects are developing, some common basic modules can be extracted separately from nexus, and the projects that need to be used can be directly pulled from Nexus (the implementation, maintenance and deployment of basic modules can be handed over to special personnel, and other projects do not need to care about code implementation, so as to ensure that the core code is not leaked)

3. In the process of some closed development, the development machine cannot access the public network, so it is more troublesome to connect the central repository and download jars. At this time, nexus can be used to build a bridge between the public network and LAN

Next, let's briefly introduce the construction of nexus and how to use nexus in Android projects

Project presentation.png

Publish library to private server

Let's take the function bar component library as an example

Configure nexus account information

Because nexus related parameters are fixed, including warehouse address, user name and password, for security reasons, we write these parameters to gradle's global configuration, and the directory is C: \ users (user name). Gradle \ gradle.properties

Configure POM parameters

Add the following POM parameters to gradle.properties under the root directory of the project

Introducing gradle scripts

Add the following reference at the end of the build.gradle file in the library. Of course, this file needs to be created and placed in the project root path. The source code is in the script interpretation

This nexus_ The upload.gradle script includes generating java source and Java doc. If the comments are incomplete, you can comment out the Android javadocsjar call in the script to avoid affecting the upload.

release

Double click uploadarchives in the gradle task on the right to compile and upload the library

up.png

Wait for a while and the word "success" will appear to prove that the upload has been successful

success.png

Finally, let's go to nexus to verify, bingo! Upload succeeded.

Script interpretation

Use library on private server

First, declare the address of the private server in the build. Gradle of the project

Then, we are most familiar with adding dependencies in the build.gradle file of module. Note that the groupid is followed by: the dependency library name should be followed by: and version number. I made the error that the reference is written after groupid.

Publish plugin to private server

The publishing steps are the same as those of library, but it needs to be mentioned that the script information needs to be deleted. Only the following are used.

Use plugin on private server

First, to configure the classpath reference in the build.gradle of the project, take the classic knife as an example

Then, in the module, build.gradle refers to the plug-in plugin

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>