ext { artifactoryBaseUrl = 'https://maven.ubtob.net/artifactory' artifactorySnapshotRepoUrl = "$artifactoryBaseUrl/libs-snapshot-local" artifactoryReleaseRepoUrl = "$artifactoryBaseUrl/libs-release-local" } apply plugin: 'maven-publish' configurations { persist } task sourcesJar(type: Jar) { baseName "${project.name}" classifier 'sources' from sourceSets.main.allSource } task persistJar(type: Jar) { baseName "sso-persist" from sourceSets.main.output exclude "spring", "config" include "**/entity/**", "**/dao/**", "**/core/**", "**/util/**", "**/support/**" } task persistSourcesJar(type: Jar) { baseName "sso-persist" classifier 'sources' from sourceSets.main.allSource exclude "spring", "config" include "**/entity/**", "**/dao/**", "**/core/**", "**/util/**", "**/support/**" } // Create artifact for other project import artifacts { persist persistJar } publishing { publications { plugin(MavenPublication) { groupId "${project.group}" artifactId "${project.name}" version "${project.version}" from components.java artifact sourcesJar } persist(MavenPublication) { groupId "${project.group}" artifactId 'sso-persist' version "${project.version}" artifact persistJar artifact persistSourcesJar } } repositories { maven { name 'myLocal' url "file://$projectDir/repo" } maven { name 'remoteArtifactory' url project.version.endsWith('-SNAPSHOT') ? artifactorySnapshotRepoUrl : artifactoryReleaseRepoUrl credentials { username = 'admin' password = 'Admin2020yourkj2021' } } } }