103 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Groovy
		
	
	
	
			
		
		
	
	
			103 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Groovy
		
	
	
	
apply plugin: 'maven-publish'
 | 
						|
apply plugin: 'signing'
 | 
						|
 | 
						|
publishing {
 | 
						|
  publications {
 | 
						|
    maven(MavenPublication) {
 | 
						|
      if (project.tasks.names.contains('shadowJar') && !findProperty('noShadowPublish')) {
 | 
						|
        project.shadow.component(it)
 | 
						|
        //These two are here just to satisfy Maven Central
 | 
						|
        artifact sourcesJar
 | 
						|
        artifact javadocJar
 | 
						|
      } else {
 | 
						|
        project.plugins.withId("java-platform") {
 | 
						|
          from(components["javaPlatform"])
 | 
						|
        }
 | 
						|
        project.plugins.withId("java-library") {
 | 
						|
          from components.java
 | 
						|
        }
 | 
						|
      }
 | 
						|
 | 
						|
      def stable = findProperty("otel.stable") ?: false
 | 
						|
      if (!stable) {
 | 
						|
        def versionParts = version.split('-')
 | 
						|
        versionParts[0] += '-alpha'
 | 
						|
        version = versionParts.join('-')
 | 
						|
      }
 | 
						|
 | 
						|
      afterEvaluate {
 | 
						|
        def mavenGroupId = project.findProperty('mavenGroupId')
 | 
						|
        if (mavenGroupId) {
 | 
						|
          groupId = mavenGroupId
 | 
						|
        }
 | 
						|
        artifactId = artifactPrefix(project, archivesBaseName) + archivesBaseName
 | 
						|
 | 
						|
        if (!groupId.startsWith("io.opentelemetry.")) {
 | 
						|
          throw new GradleException("groupId is not set for this project or its parent $project.parent")
 | 
						|
        }
 | 
						|
      }
 | 
						|
 | 
						|
      pom {
 | 
						|
        name = 'OpenTelemetry Instrumentation for Java'
 | 
						|
        url = 'https://github.com/open-telemetry/opentelemetry-java-instrumentation'
 | 
						|
 | 
						|
        licenses {
 | 
						|
          license {
 | 
						|
            name = 'The Apache License, Version 2.0'
 | 
						|
            url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
 | 
						|
          }
 | 
						|
        }
 | 
						|
 | 
						|
        developers {
 | 
						|
          developer {
 | 
						|
            id = 'opentelemetry'
 | 
						|
            name = 'OpenTelemetry'
 | 
						|
            url = 'https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions'
 | 
						|
          }
 | 
						|
        }
 | 
						|
 | 
						|
        scm {
 | 
						|
          connection = 'scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git'
 | 
						|
          developerConnection = 'scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git'
 | 
						|
          url = 'git@github.com:open-telemetry/opentelemetry-java-instrumentation.git'
 | 
						|
        }
 | 
						|
 | 
						|
        afterEvaluate {
 | 
						|
          // description is not available until evaluated.
 | 
						|
          description = project.description ?: 'Instrumentation of Java libraries using OpenTelemetry.'
 | 
						|
        }
 | 
						|
      }
 | 
						|
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
private String artifactPrefix(Project p, String archivesBaseName) {
 | 
						|
  if (archivesBaseName.startsWith("opentelemetry")) {
 | 
						|
    return ''
 | 
						|
  }
 | 
						|
  if (p.name.startsWith("opentelemetry")) {
 | 
						|
    return ''
 | 
						|
  }
 | 
						|
  if (p.name.startsWith("javaagent")) {
 | 
						|
    return 'opentelemetry-'
 | 
						|
  }
 | 
						|
  if (p.group == 'io.opentelemetry.javaagent.instrumentation') {
 | 
						|
    return 'opentelemetry-javaagent-'
 | 
						|
  }
 | 
						|
  return 'opentelemetry-'
 | 
						|
}
 | 
						|
 | 
						|
rootProject.tasks.named('release').configure {
 | 
						|
  finalizedBy tasks.publishToSonatype
 | 
						|
}
 | 
						|
 | 
						|
// Stub out entire signing block off of CI since Gradle provides no way of lazy configuration of
 | 
						|
// signing tasks.
 | 
						|
if (System.getenv("CI") != null) {
 | 
						|
  signing {
 | 
						|
    useInMemoryPgpKeys(System.getenv("GPG_PRIVATE_KEY"), System.getenv("GPG_PASSWORD"))
 | 
						|
    sign publishing.publications.maven
 | 
						|
  }
 | 
						|
}
 |