File: publish.gradle

package info (click to toggle)
gradle 4.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 85,104 kB
  • sloc: java: 319,724; xml: 14,356; cpp: 4,200; ansic: 1,025; sh: 300; makefile: 60; asm: 17; jsp: 17; objc: 10
file content (73 lines) | stat: -rw-r--r-- 2,321 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
apply plugin: 'maven'

configurations {
    publishCompile
    publishRuntime
    compile {
        extendsFrom publishCompile
    }
}

task sourceJar(type: Jar) {
    classifier = 'sources'
    from { sourceSets.main.java.srcDirs + sourceSets.main.groovy.srcDirs }
}

task generatePom {
    ext.pomFile = new File(temporaryDir, 'pom.xml')
    doLast {
        dependencies {
            configurations.publishCompile.allDependencies.withType(ProjectDependency).each {
                publishRuntime "org.gradle:${it.dependencyProject.archivesBaseName}:${version}"
            }
            configurations.publishCompile.allDependencies.withType(ExternalDependency).each {
                publishRuntime it
            }
        }

        def localDeployer = install.repositories.mavenInstaller

        configure(localDeployer) {
            pom.scopeMappings.mappings.clear()
            pom.scopeMappings.addMapping(300, configurations.publishRuntime, Conf2ScopeMappingContainer.RUNTIME)
            pom.groupId = project.group
            pom.artifactId = archivesBaseName
            pom.version = version
            pom.writeTo(pomFile)
        }
    }
}

artifacts {
    publishRuntime jar
    publishRuntime sourceJar
    publishRuntime new org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact(archivesBaseName, 'pom', 'pom', null, new Date(), generatePom.pomFile, generatePom)
}

uploadArchives { task ->
    onlyIf { !project.hasProperty("noUpload") }

    gradle.taskGraph.whenReady { graph ->
        if (graph.hasTask(task)) {
            // check properties defined and fail early
            artifactoryUserName
            artifactoryUserPassword
        }
    }

    configuration = configurations.publishRuntime
    dependsOn generatePom
    uploadDescriptor = false
    doFirst {
        repositories {
            ivy {
                def repo = "https://gradle.artifactoryonline.com/gradle/libs-${isSnapshot ? 'snapshots' : 'releases'}-local"
                artifactPattern "${repo}/${project.group.replaceAll('\\.', '/')}/${archivesBaseName}/[revision]/[artifact]-[revision](-[classifier]).[ext]"
                credentials {
                    username = artifactoryUserName
                    password = artifactoryUserPassword
                }
            }
        }
    }
}