blob: 274ecbead8234784f370688f3ab41ed8c979d324 [file] [log] [blame]
/*
* Copyright (C) 2020 The Dagger Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
google()
jcenter()
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.4.20'
id 'java-gradle-plugin'
id 'maven-publish'
}
repositories {
google()
jcenter()
}
configurations {
additionalTestPlugin {
canBeConsumed = false
canBeResolved = true
extendsFrom implementation
}
}
dependencies {
implementation gradleApi()
compileOnly 'com.android.tools.build:gradle:4.2.0-beta04'
// TODO(danysantiago): Make compileOnly to avoid dep for non-Kotlin projects.
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20'
implementation 'org.javassist:javassist:3.26.0-GA'
implementation 'org.ow2.asm:asm:9.0'
testImplementation gradleTestKit()
testImplementation 'junit:junit:4.12'
testImplementation 'com.google.truth:truth:1.0.1'
additionalTestPlugin 'com.android.tools.build:gradle:4.2.0-beta04'
}
// Configure the generating task of plugin-under-test-metadata.properties to
// include additional dependencies for the injected plugin classpath that
// are not present in the main runtime dependencies. This allows us to test
// the desired AGP version while keeping a compileOnly dep on the main source.
tasks.withType(PluginUnderTestMetadata.class).named("pluginUnderTestMetadata").configure {
it.pluginClasspath.from(configurations.additionalTestPlugin)
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
// Create sources Jar from main kotlin sources
tasks.register("sourcesJar", Jar).configure {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles sources JAR"
classifier = "sources"
from(sourceSets["main"].allSource)
}
// Create javadoc Jar. The jar is empty since we don't really have docs
// for this plugin but this is required to upload to Sonatype.
// https://central.sonatype.org/pages/requirements.html#supply-javadoc-and-sources
tasks.register("javadocJar", Jar).configure {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles javadoc JAR"
classifier = "javadoc"
}
// Disable Gradle metadata publication.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
// TODO(danysantiago): Use POM template in tools/ to avoid duplicating lines.
publishing {
publications {
plugin(MavenPublication) {
artifactId = 'hilt-android-gradle-plugin'
def publishVersion = findProperty("PublishVersion")
version = (publishVersion != null) ? publishVersion : "LOCAL-SNAPSHOT"
from components.kotlin
artifact(sourcesJar)
artifact(javadocJar)
pom {
name = 'Hilt Android Gradle Plugin'
description = 'A fast dependency injector for Android and Java.'
url = 'https://github.com/google/dagger'
scm {
url = 'https://github.com/google/dagger/'
connection = 'scm:git:git://github.com/google/dagger.git'
developerConnection = 'scm:git:ssh://git@github.com/google/dagger.git'
tag = 'HEAD'
}
issueManagement {
system = 'GitHub Issues'
url = 'https://github.com/google/dagger/issues'
}
licenses {
license {
name = 'Apache 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
organization {
name = 'Google, Inc.'
url = 'https://www.google.com'
}
withXml {
def projectNode = asNode()
// Adds:
// <parent>
// <groupId>org.sonatype.oss</groupId>
// <artifactId>oss-parent</artifactId>
// <version>7</version>
// </parent>
def parentNode = projectNode.appendNode('parent')
parentNode.appendNode('groupId', 'org.sonatype.oss')
parentNode.appendNode('artifactId', 'oss-parent')
parentNode.appendNode('version', '7')
// Adds scm->tag because for some reason the DSL API does not.
// <scm>
// <tag>HEAD</tag>
// </scm>
projectNode.get('scm').first().appendNode('tag', 'HEAD')
}
}
}
}
// Publish to build output repository.
repositories {
maven {
url = uri("$buildDir/repo")
}
}
}
group='com.google.dagger'