buildscript { ext.kotlinVersion = '1.4.0' repositories { mavenLocal() jcenter() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" } } allprojects { apply plugin: "maven-publish" apply plugin: 'java' apply plugin: 'kotlin' apply plugin: 'maven' group 'cn.tursom' version '0.1' sourceCompatibility = 1.8 repositories { mavenLocal() mavenCentral() } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" testImplementation group: 'junit', name: 'junit', version: '4.12' } compileKotlin { kotlinOptions.jvmTarget = "1.8" } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } //打包源代码 task sourcesJar(type: Jar, dependsOn: classes) { //classifier = 'sources' archiveClassifier.set('sources') from sourceSets.main.allSource } artifacts { archives sourcesJar } publishing { repositories { maven { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/tursom/TursomServer") credentials { //username = project.findProperty("gpr.user") ?: System.getenv("USERNAME") username = "tursom" password = project.findProperty("gpr.key") ?: System.getenv("PASSWORD") } } } publications { gpr(MavenPublication) { from(components.java) } } } }