aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: ac68ffd5b63c0fb86814c01f44d892076472c1fc (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
plugins {
    id "net.ltgt.errorprone" version "3.1.0" apply false
}

subprojects {
    apply plugin: "checkstyle"
    apply plugin: "java-library"
    apply plugin: 'maven-publish'
    apply plugin: "idea"
    apply plugin: "signing"
    apply plugin: "net.ltgt.errorprone"

    repositories {
        maven {
            url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
        mavenCentral()
    }

    java {
        toolchain {
            languageVersion = JavaLanguageVersion.of(17)
        }
    }
    
    task javadocJar(type: Jar) {
        archiveClassifier = 'javadoc'
        from javadoc
    }

    task sourcesJar(type: Jar) {
        archiveClassifier = 'sources'
        from sourceSets.main.allSource
    }

    checkstyle {
        configDirectory = file("$rootDir/buildscripts")
        toolVersion = "6.17"
        ignoreFailures = false
        if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
            ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
        }
    }

    afterEvaluate {
        jar {
            manifest {
                attributes ("Automatic-Module-Name": moduleName,
                    "Implementation-Version": archiveVersion.get(),
                    "Implementation-Title": "PerfMark (https://www.perfmark.io/)",
                    "Implementation-Vendor":
                            "Carl Mastrangelo https://www.carlmastrangelo.com/ https://twitter.com/CarlMastrangelo",
                    "Specification-Version": archiveVersion.get(),
                    "Specification-Title": "PerfMark (https://www.perfmark.io/)",
                    "Specification-Vendor": "Carl Mastrangelo (https://www.perfmark.io/)",
                    "Carl-Is-Awesome": "true")
            }
        }
    }


    publishing {
        publications {
            maven(MavenPublication) {
                from components.java

                artifact javadocJar
                artifact sourcesJar

                pom {
                    name = project.group + ":" + project.name
                    url = 'https://github.com/perfmark/perfmark'
                    afterEvaluate {
                        // description is not available until evaluated.
                        description = project.description
                    }

                    scm {
                        connection = 'scm:git:https://github.com/perfmark/perfmark.git'
                        developerConnection = 'scm:git@github.com:perfmark/perfmark.git'
                        url = 'https://github.com/perfmark/perfmark'
                    }

                    licenses {
                        license {
                            name = 'Apache 2.0'
                            url = 'https://opensource.org/licenses/Apache-2.0'
                        }
                    }

                    developers {
                        developer {
                            id = "carl-mastrangelo"
                            name = "Carl Mastrangelo"
                            email = "carl@carlmastrangelo.com"
                            url = "https://www.perfmark.io/"
                        }
                    }
                }
            }
        }

        repositories {
             maven {
                 def stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
                 def releaseUrl = stagingUrl
                 def snapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
                 url = version.endsWith('SNAPSHOT') ? snapshotUrl : releaseUrl
                 credentials {
                     if (rootProject.hasProperty('ossrhUsername')
                             && rootProject.hasProperty('ossrhPassword')) {
                         username = rootProject.ossrhUsername
                         password = rootProject.ossrhPassword
                     }
                 }
            }
        }
    }
    
    signing {
        required false
        sign publishing.publications.maven
    }

    [publishMavenPublicationToMavenRepository, publishMavenPublicationToMavenLocal]*.onlyIf {
        !name.contains("perfmark-examples") && !name.contains("perfmark-api-testing")
                && !name.contains("perfmark-testing") && !name.contains("perfmark-agent")
                && !name.contains("perfmark-java19")
    }

    [javadoc]*.onlyIf {
        !name.contains("perfmark-java9") && !name.contains("perfmark-examples")
                && !name.contains("perfmark-api-testing") && !name.contains("perfmark-testing")
    }

    if (rootProject.properties.get('errorProne', true)) {
        dependencies {
            errorprone 'com.google.errorprone:error_prone_core:2.27.0'
            errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
        }
    } else {
        // Disable Error Prone
        allprojects {
            afterEvaluate { project ->
                project.tasks.withType(JavaCompile) {
                    options.errorprone.enabled = false
                }
            }
        }
    }

    group = "io.perfmark"
    version = "0.28.0-SNAPSHOT"

    dependencies {
        testImplementation libs.junit
    }
}