Nexus使用

news2025/1/13 15:36:23

环境

apache-maven-3.5.4+nexus-3.38.1-01

Android开发中常用的maven代理地址

  • 阿里云:http://maven.aliyun.com/nexus/content/groups/public/
  • google:https://dl.google.com/dl/android/maven2/
  • jcenter:https://jcenter.bintray.com/
  • mavenCentral:Central Repository:
  • jitpack:JitPack | Publish JVM and Android libraries

常用指令

启动(nexus-3.38.1-01版本)

nexus /run

自动启动

nexus /install nexus

Nexus设置

密码在D:\programtools\nexus-3.38.1-01-win64\sonatype-work\nexus3\admin.password目录中

使用默认的maven仓库即可

本地maven配置

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
| This is the configuration file for Maven. It can be specified at two levels:
|
|  1. User Level. This settings.xml file provides configuration for a single user,
|                 and is normally provided in ${user.home}/.m2/settings.xml.
|
|                 NOTE: This location can be overridden with the CLI option:
|
|                 -s /path/to/user/settings.xml
|
|  2. Global Level. This settings.xml file provides configuration for all Maven
|                 users on a machine (assuming they're all using the same Maven
|                 installation). It's normally provided in
|                 ${maven.conf}/settings.xml.
|
|                 NOTE: This location can be overridden with the CLI option:
|
|                 -gs /path/to/global/settings.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
| values (values used when the setting is not specified) are provided.
|
|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
  | The path to the local repository maven will use to store artifacts.
  |
  | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <!-- interactiveMode
  | This will determine whether maven prompts you when it needs input. If set to false,
  | maven will use a sensible default value, perhaps based on some other setting, for
  | the parameter in question.
  |
  | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
  | Determines whether maven should attempt to connect to the network when executing a build.
  | This will have an effect on artifact downloads, artifact deployment, and others.
  |
  | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
  | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
  | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
  | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
  |-->
  <pluginGroups>
  <!-- pluginGroup
  | Specifies a further group identifier to use for plugin lookup.
  <pluginGroup>com.your.plugins</pluginGroup>
  -->
</pluginGroups>

  <!-- proxies
  | This is a list of proxies which can be used on this machine to connect to the network.
  | Unless otherwise specified (by system property or command-line switch), the first proxy
  | specification in this list marked as active will be used.
  |-->
  <proxies>
  <!-- proxy
  | Specification for one proxy, to be used in connecting to the network.
  |
  <proxy>
  <id>optional</id>
  <active>true</active>
  <protocol>http</protocol>
  <username>proxyuser</username>
  <password>proxypass</password>
  <host>proxy.host.net</host>
  <port>80</port>
  <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
  -->
</proxies>

  <!-- servers
  | This is a list of authentication profiles, keyed by the server-id used within the system.
  | Authentication profiles can be used whenever maven must make a connection to a remote server.
  |-->
  <servers>
  <!-- server
  | Specifies the authentication information to use when connecting to a particular server, identified by
  | a unique name within the system (referred to by the 'id' attribute below).
  |
  | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
  |       used together.
  |
  <server>
  <id>deploymentRepo</id>
  <username>repouser</username>
  <password>repopwd</password>
</server>
  -->

  <!-- Another sample, using keys to authenticate.
  <server>
  <id>siteServer</id>
  <privateKey>/path/to/private/key</privateKey>
  <passphrase>optional; leave empty if not used.</passphrase>
</server>
  -->

  <server>
  <id>releases</id>
  <username>admin</username>
  <password>admin123</password>
</server>
  <server>
  <id>snapshots</id>
  <username>admin</username>
  <password>admin123</password>
</server>

</servers>

  <!-- mirrors
  | This is a list of mirrors to be used in downloading artifacts from remote repositories.
  |
  | It works like this: a POM may declare a repository to use in resolving certain artifacts.
  | However, this repository may have problems with heavy traffic at times, so people have mirrored
  | it to several places.
  |
  | That repository definition will have a unique id, so we can create a mirror reference for that
  | repository, to be used as an alternate download site. The mirror site will be the preferred
  | server for that repository.
  |-->
  <mirrors>
  <!-- mirror
  | Specifies a repository mirror site to use instead of a given repository. The repository that
  | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
  | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
  |
  <mirror>
  <id>mirrorId</id>
  <mirrorOf>repositoryId</mirrorOf>
  <name>Human Readable Name for this Mirror.</name>
  <url>http://my.repository.com/repo/path</url>
</mirror>
  -->
  <mirror>
  <id>alimaven</id>
  <mirrorOf>central</mirrorOf>
  <name>aliyun maven</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>

  <mirror>
  <id>maven-default-http-blocker</id>
  <mirrorOf>external:http:*</mirrorOf>
  <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
  <url>http://0.0.0.0/</url>
  <blocked>true</blocked>
</mirror>

</mirrors>

  <!-- profiles
  | This is a list of profiles which can be activated in a variety of ways, and which can modify
  | the build process. Profiles provided in the settings.xml are intended to provide local machine-
  | specific paths and repository locations which allow the build to work in the local environment.
  |
  | For example, if you have an integration testing plugin - like cactus - that needs to know where
  | your Tomcat instance is installed, you can provide a variable here such that the variable is
  | dereferenced during the build process to configure the cactus plugin.
  |
  | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
  | section of this document (settings.xml) - will be discussed later. Another way essentially
  | relies on the detection of a system property, either matching a particular value for the property,
  | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
  | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
  | Finally, the list of active profiles can be specified directly from the command line.
  |
  | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
  |       repositories, plugin repositories, and free-form properties to be used as configuration
  |       variables for plugins in the POM.
  |
  |-->
  <profiles>
  <!-- profile
  | Specifies a set of introductions to the build process, to be activated using one or more of the
  | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
  | or the command line, profiles have to have an ID that is unique.
  |
  | An encouraged best practice for profile identification is to use a consistent naming convention
  | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
  | This will make it more intuitive to understand what the set of introduced profiles is attempting
  | to accomplish, particularly when you only have a list of profile id's for debug.
  |
  | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
  <profile>
  <id>jdk-1.4</id>

  <activation>
  <jdk>1.4</jdk>
</activation>

  <repositories>
  <repository>
  <id>jdk14</id>
  <name>Repository for JDK 1.4 builds</name>
  <url>http://www.myhost.com/maven/jdk14</url>
  <layout>default</layout>
  <snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
  -->

  <!--
  | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
  | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
  | might hypothetically look like:
  |
  | ...
  | <plugin>
  |   <groupId>org.myco.myplugins</groupId>
  |   <artifactId>myplugin</artifactId>
  |
  |   <configuration>
  |     <tomcatLocation>${tomcatPath}</tomcatLocation>
  |   </configuration>
  | </plugin>
  | ...
  |
  | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
  |       anything, you could just leave off the <value/> inside the activation-property.
  |
  <profile>
  <id>env-dev</id>

  <activation>
  <property>
  <name>target-env</name>
  <value>dev</value>
</property>
</activation>

  <properties>
  <tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
  -->
  <profile>
  <id>nexusProfile</id>
  <repositories>
  <repository>
  <id>snapshots</id>
  <url>http://localhost:8081/repository/maven-snapshots/</url>
  <layout>default</layout>
  <releases>
  <enabled>true</enabled>
</releases>

</repository>
  <repository>
  <id>releases</id>
  <url>http://localhost:8081/repository/maven-releases/</url>
  <layout>default</layout>
  <snapshots>
  <enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

  <!-- activeProfiles
  | List of profiles that are active for all builds.
  |
  <activeProfiles>
  <activeProfile>alwaysActiveProfile</activeProfile>
  <activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
  -->

  <localRepository>D:/programtools/maven/MavenRepository</localRepository>

  <!--激活 -->
  <activeProfiles>
  <activeProfile>nexusProfile</activeProfile>
</activeProfiles>

</settings>

Gradle 6x以下版本

android工程配置

工程build.gradle配置

    repositories {
        google()
        mavenCentral()

        maven {
            allowInsecureProtocol(true)
            url 'http://localhost:8081/repository/kasax/'
        }
        maven {
            allowInsecureProtocol(true)
            url 'http://localhost:8081/repository/kasax-snapshot/'
        }
    }

maven-upload.gradle

apply plugin: 'maven'

def RELEASE_REPOSITORY_URL = "http://localhost:8081/repository/maven-releases/"
def SNAPSHOT_REPOSITORY_URL = "http://localhost:8081/repository/maven-snapshots/"
def NEXUS_USERNAME = "admin" 
def NEXUS_PASSWORD = "admin123"
def PUBLISH_PACHAGE = 'aar'//打包类型,根据场景可选jar或aar


//上传到快照Maven
task uploadArchivesSpapshot(type: Upload, group: "upload") {
    configuration = configurations.archives
    repositories {
        mavenDeployer {
            pom.groupId = GROUP
            pom.artifactId = POM_ARTIFACT_ID
            pom.version = VERSION_NAME + "-SNAPSHOT"
            pom.packaging = PUBLISH_PACHAGE
            repository(url: SNAPSHOT_REPOSITORY_URL) {
                authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
            }
        }
    }
}

//上传到生产Maven
task uploadArchivesRelease(type: Upload, group: "upload") {
    configuration = configurations.archives
    repositories {
        mavenDeployer {
            pom.groupId = GROUP
            pom.artifactId = POM_ARTIFACT_ID
            pom.version = VERSION_NAME
            repository(url: RELEASE_REPOSITORY_URL) {
                authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
            }
        }
    }
}

//上传到快照Maven和生产Maven
task uploadArchivesAll(group: "upload") {
    dependsOn(uploadArchivesSpapshot, uploadArchivesRelease)
}

//aar包内包含注释
task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.sourceFiles
}

artifacts {
    archives androidSourcesJar
}

使用模块的配置

ext.GROUP="com.kasax"
ext.POM_ARTIFACT_ID="testvideosdk"
ext.VERSION_NAME=android.defaultConfig.versionName

apply from: '../maven_upload.gradle'

上传aar至maven

日志

使用maven依赖

项目build.gradle配置

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
        maven { url 'https://jitpack.io' }
        maven { url 'https://repo1.maven.org/maven2/' }
        maven { url 'https://developer.huawei.com/repo/' }

        maven {
            allowInsecureProtocol(true)
            url 'http://localhost:8081/repository/maven-snapshots/'
            credentials {
                username 'admin'
                password 'admin123'
            }
        }

        maven {
            allowInsecureProtocol(true)
            url 'http://localhost:8081/repository/maven-releases/'
            credentials {
                username 'admin'
                password 'admin123'
            }
        }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
        maven { url 'https://jitpack.io' }
        maven { url 'https://repo1.maven.org/maven2/' }
        maven { url 'https://developer.huawei.com/repo/' }

        maven {
            allowInsecureProtocol(true)
            url 'http://localhost:8081/repository/maven-snapshots/'
            credentials {
                username 'admin'
                password 'admin123'
            }
        }

        maven {
            allowInsecureProtocol(true)
            url 'http://localhost:8081/repository/maven-releases/'
            credentials {
                username 'admin'
                password 'admin123'
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

使用的模块配置

    implementation 'com.kasax:testvideosdk:4.0'

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/162766.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Leetcode:236. 二叉树的最近公共祖先(C++)

目录 问题描述&#xff1a; 实现代码与解析&#xff1a; 原理思路: 问题描述&#xff1a; 给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。 百度百科中最近公共祖先的定义为&#xff1a;“对于有根树 T 的两个节点 p、q&#xff0c;最近公共祖先表示为一个节点 x&…

Xmanager7远程登录ubuntu20.04

Xmanager7远程登录ubuntu20.04 本文不介绍Xmanager7的下载和安装方法&#xff0c;详细内容可以参考【实用软件】Xmanager 7.0安装教程 - 哔哩哔哩 (bilibili.com)。关于Xmanager7远程登录的教材参考于 (149条消息) Xmanager远程桌面教程_周先森爱吃素的博客-CSDN博客_xmanage…

代码随想录第60天|84.柱状图中最大的矩形

84.柱状图中的最大的图形 总体思路&#xff1a;找到左右两个方向第一个小于该柱子高度的下标&#xff0c;用右下标-左下标-1得到该柱子高度对应的宽度w,再用宽度w*高度h得到面积&#xff0c;返回面积最大值 双指针法&#xff08;超时&#xff09; for循环判断左右第一个小于…

【NI Multisim 14.0虚拟仪器设计——虚拟仪器的引入】

目录 序言 前言 &#x1f349;知识点 一、虚拟仪器的引入 &#x1f34a;1.工具栏 &#x1f34a; 2.基本操作 ①仪器的选用与连接 ②仪器参数的设置 序言 NI Multisim最突出的特点之一就是用户界面友好。它可以使电路设计者方便、快捷地使用虚拟元器件和仪器、仪表进行电…

Linux云服务器下的gitee提交代码方法

目录 创建一个gitee仓库 gitee提交代码三板斧 1. git add 提交的文件 2. git commit -m "提交日志" 3. git push 可能存在的问题 .gitignore介绍 如何删除文件 创建一个gitee仓库 gitee提交代码三板斧 1. git add 提交的文件 作用&#xff1a;添加我…

Electron + React 应用打包全流程

&#xff08;第一次用 Typora 写博&#xff0c;希望效果不错~&#xff09; 这几天有个创意编程比赛&#xff0c;要写一个电脑端应用。我准备用 React.js Electron 做&#xff08;因为熟悉~&#xff09;&#xff0c;编程部分一路风雨无阻&#xff0c;到了打包却出现了问题。El…

多轮对话(一):概述(意图识别+槽填充)

一、对话系统 基于流水线的面向任务的对话系统包含了四个关键部分&#xff1a; 语言理解。它被称为自然语言理解&#xff08;NLU&#xff09;&#xff0c;它把用户话语解析为预定义的语义槽。对话状态跟踪器。它管理每一轮的输入与对话历史&#xff0c;输出当前对话状态。对话…

Sechunter移动应用隐私合规检测详解

概述&#xff1a; 受益于移动设备的广泛普及&#xff0c;移动应用近年来得到了蓬勃发展。基于移动设备集成的各类传感器&#xff0c;众多功能丰富的移动应用被开发出来&#xff0c;聚集了大量高价值用户隐私数据&#xff0c;包括用户身份信息、地理位置信息、账户资料信息等。…

玩转机密计算从 secGear 开始

随着网络与计算业务的快速发展&#xff0c;数据成为数字经济的关键生产要素&#xff0c;如何高质量挖掘数据价值&#xff0c;构建安全、合规、可信的数据流通&#xff0c;成为推动数字经济健康发展的关键。此外&#xff0c;根据我国个人信息保护法、欧盟通用数据保护条例 GDPR …

IDEA安装使用代码提交模板

IDEA安装使用代码提交模板 1. idea安装git commit template插件 2、重启idea 3、选择要提交的文件右击&#xff08;或CtrlShiftK&#xff09;&#xff0c;如下图&#xff1a; 3.1 Type of change用于说明commit的类别,常用的标识如下&#xff1a; feat: 新功能&#xff08;f…

501. 二叉搜索树中的众数

501. 二叉搜索树中的众数 难度简单 给你一个含重复值的二叉搜索树&#xff08;BST&#xff09;的根节点 root &#xff0c;找出并返回 BST 中的所有 众数&#xff08;即&#xff0c;出现频率最高的元素&#xff09;。 如果树中有不止一个众数&#xff0c;可以按 任意顺序 返…

Effective C++条款38:通过复合塑模出 has-a 或“根据某物实现出“

Effective C条款38&#xff1a;通过复合塑模出 has-a 或"根据某物实现出"&#xff08;Model "has-a" or "is-implemented-in-terms-of" through composition&#xff09;条款38&#xff1a;通过复合塑模出 has-a 或"根据某物实现出"1、…

Batch Normalization

1、原理 在图像预处理过程中会对图像进行标准化处理&#xff0c;这样能够加速网络的收敛速度。 如下图所示&#xff0c;对于Conv1来说输入的是满足某一分布的特征矩阵&#xff0c;但对于Conv2来说输入的feature map就不一定满足某一分布规律。 Batch Normalization的目的就是使…

大坝安全在线监控系统包含哪些内容?怎样提升水库大坝信息化管理水平?

平升电子大坝安全在线监控系统根据SL551-2012《土石坝安全监测技术规范》的整编要求&#xff0c;设置了变形监测、渗流监测、环境量监测。大坝安全在线监控系统可及时了解大坝的工作性态和水库可能存在的事故隐患&#xff0c;为大坝安全管理与水库运行调度提供了准确、及时的现…

Elasticsearch集群搭建

前言在如今的开发过程中&#xff0c;单节点的Elasticsearch肯定是支撑不了大数据量的&#xff0c;而且还存在单节点故障的问题&#xff0c;所以Elasticsearch也提供了集群功能&#xff0c;像其他中间件也基本都会考虑到这个问题准备信息首先&#xff0c; 由于我机器有限&#x…

如何在虚拟机上安装Linx系统

前言作为Java开发的我们&#xff0c;可能有时候想自己玩玩linux服务器&#xff0c;但是如果买阿里云或者腾讯云的服务器又很贵&#xff0c;这时候我们就可以在自己电脑上安装虚拟机了&#xff0c;这也是本篇文章出现的原因&#xff0c;下面我就安装centOS7为例子来进行介绍首先…

openEuler资源利用率提升之道 05:虚机混部介绍与功耗管理技术

随着云计算市场规模的快速增长&#xff0c;各云厂商基础设施投入也不断增加&#xff0c;但行业普遍存在资源利用率低的问题&#xff0c;在上述背景下&#xff0c;提升资源利用率已经成为了一个重要的技术课题。将业务区分优先级混合部署(下文简称混部)是典型有效的资源利用率提…

【C语言】使用C语言实现静态、动态的通讯录(简单易懂)

我们在学习结构体之后&#xff0c;就可以尝试去实现通讯录的制作&#xff0c;如果您这边对于结构体还没有太多的认识的话&#xff0c;请先访问这一篇文章,会有利于接下来的学习。【自定义类型】带你走进结构体、枚举、联合_小王学代码的博客-CSDN博客 目录 一、通讯录 二、静…

JVM-【面试题】-对象内存分配

一、对象内存分配流程图如果能在栈分布就直接在栈创建如果是大对象就直接在old区创建如果不大于TLAB则在TLAB创建&#xff0c;否则在Eden区创建如果Eden区空间不足就会发生Minor GC进行回收&#xff0c;回收的空间放不下或年龄达到上限就直接放到Old区&#xff0c;之后S0区的存…

Vue3.0 性能提升主要是通过哪几方面体现的?

一、编译阶段 回顾Vue2&#xff0c;每个组件实例都对应一个 watcher 实例&#xff0c;它会在组件渲染的过程中把用到的数据property记录为依赖&#xff0c;当依赖发生改变&#xff0c;触发setter&#xff0c;则会通知watcher&#xff0c;从而使关联的组件重新渲染 试想一下&…