设置云效仓库参数到环境变量及gradle使用

1、 需打开powershell执行以下代码,value替换为仓库对应地址/账号/密码
[environment]::SetEnvironmentvariable("MAVEN_REPO_SNAPSHOT_URL", "https://packages.aliyun.com/maven/repository/2xxx-snapshot-1wNmas/", "User")
[environment]::SetEnvironmentvariable("MAVEN_REPO_RELEASE_URL", "https://packages.aliyun.com/maven/repository/xxx-release-Y8y0H2/", "User")
[environment]::SetEnvironmentvariable("MAVEN_DEPLOY_USER", "5ed75aaxxxx5a83af", "User")
[environment]::SetEnvironmentvariable("MAVEN_DEPLOY_PASSWORD", "e2gxxxxsi", "User")
2、gradle配置示例
plugins {  
	id 'org.springframework.boot' version '3.2.4'  
	id 'io.spring.dependency-management' version '1.1.4'  
}  
  
group = 'com.fafa'  
  
subprojects {  
	apply plugin: 'org.springframework.boot'  
	apply plugin: 'io.spring.dependency-management'  
	apply plugin: 'java'  
	  
	sourceCompatibility = 17  
	targetCompatibility = 17  
	  
	ext {  
        //获取系统环境变量
		MAVEN_REPO_RELEASE_URL = System.getenv('MAVEN_REPO_RELEASE_URL')  
		MAVEN_REPO_SNAPSHOT_URL = System.getenv('MAVEN_REPO_SNAPSHOT_URL')  
		MAVEN_DEPLOY_USER = System.getenv('MAVEN_DEPLOY_USER')  
		MAVEN_DEPLOY_PASSWORD = System.getenv('MAVEN_DEPLOY_PASSWORD')  
	}  
	  
	repositories {  
		maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }  
		maven {  
			url 'https://maven.aliyun.com/repository/public'  
		}  
		maven { url "https://repo.spring.io/milestone" }  
		maven { url "https://plugins.gradle.org/m2/" }  
		maven {  
			credentials {  
				username MAVEN_DEPLOY_USER  
				password MAVEN_DEPLOY_PASSWORD  
			}  
			url MAVEN_REPO_RELEASE_URL  
		}  
		maven {  
			credentials {  
				username MAVEN_DEPLOY_USER  
				password MAVEN_DEPLOY_PASSWORD  
			}  
			url MAVEN_REPO_SNAPSHOT_URL  
		}  
		mavenCentral()  
	}  
	  
	dependencies {  
		//Spring Boot Web 启动器  
		implementation 'org.springframework.boot:spring-boot-starter-web'  
		  
		compileOnly 'org.projectlombok:lombok'  
		runtimeOnly 'com.mysql:mysql-connector-j'  
		annotationProcessor 'org.projectlombok:lombok'  
		  
		testImplementation 'org.springframework.boot:spring-boot-starter-test' 
	}  
	  
	test {  
		useJUnitPlatform()  
	}  
	  
	sourceSets {  
		main {  
		resources {  
			srcDirs = ['src/main/resources']  
			}  
		}  
	}  
	  
	tasks.withType(JavaCompile) {  
		options.encoding = "UTF-8"  
		doLast {  
			copy {  
				from sourceSets.main.resources  
				into "$buildDir/resources/main"  
			}  
		}  
	}  
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值