• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2020 The Dagger Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17buildscript {
18  repositories {
19    google()
20    mavenCentral()
21    jcenter()
22  }
23}
24
25plugins {
26  id 'org.jetbrains.kotlin.jvm' version '1.4.20'
27  id 'java-gradle-plugin'
28  id 'maven-publish'
29}
30
31repositories {
32  google()
33  mavenCentral()
34  jcenter()
35}
36
37configurations {
38  additionalTestPlugin {
39    canBeConsumed = false
40    canBeResolved = true
41    extendsFrom implementation
42  }
43}
44
45dependencies {
46  implementation gradleApi()
47  compileOnly 'com.android.tools.build:gradle:4.2.0-beta04'
48  // TODO(danysantiago): Make compileOnly to avoid dep for non-Kotlin projects.
49  implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20'
50  implementation 'org.javassist:javassist:3.26.0-GA'
51  implementation 'org.ow2.asm:asm:9.0'
52
53  testImplementation gradleTestKit()
54  testImplementation 'junit:junit:4.12'
55  testImplementation 'com.google.truth:truth:1.0.1'
56  additionalTestPlugin 'com.android.tools.build:gradle:4.2.0-beta04'
57}
58
59// Configure the generating task of plugin-under-test-metadata.properties to
60// include additional dependencies for the injected plugin classpath that
61// are not present in the main runtime dependencies. This allows us to test
62// the desired AGP version while keeping a compileOnly dep on the main source.
63tasks.withType(PluginUnderTestMetadata.class).named("pluginUnderTestMetadata").configure {
64  it.pluginClasspath.from(configurations.additionalTestPlugin)
65}
66
67compileKotlin {
68  kotlinOptions {
69    jvmTarget = "1.8"
70  }
71}
72
73// Create sources Jar from main kotlin sources
74tasks.register("sourcesJar", Jar).configure {
75  group = JavaBasePlugin.DOCUMENTATION_GROUP
76  description = "Assembles sources JAR"
77  classifier = "sources"
78  from(sourceSets["main"].allSource)
79}
80
81// Create javadoc Jar. The jar is empty since we don't really have docs
82// for this plugin but this is required to upload to Sonatype.
83// https://central.sonatype.org/pages/requirements.html#supply-javadoc-and-sources
84tasks.register("javadocJar", Jar).configure {
85  group = JavaBasePlugin.DOCUMENTATION_GROUP
86  description = "Assembles javadoc JAR"
87  classifier = "javadoc"
88}
89
90// Disable Gradle metadata publication.
91tasks.withType(GenerateModuleMetadata) {
92  enabled = false
93}
94
95// TODO(danysantiago): Use POM template in tools/ to avoid duplicating lines.
96publishing {
97  publications {
98    plugin(MavenPublication) {
99      artifactId = 'hilt-android-gradle-plugin'
100      def publishVersion = findProperty("PublishVersion")
101      version = (publishVersion != null) ? publishVersion : "LOCAL-SNAPSHOT"
102      from components.kotlin
103      artifact(sourcesJar)
104      artifact(javadocJar)
105      pom {
106        name = 'Hilt Android Gradle Plugin'
107        description = 'A fast dependency injector for Android and Java.'
108        url = 'https://github.com/google/dagger'
109        scm {
110          url = 'https://github.com/google/dagger/'
111          connection = 'scm:git:git://github.com/google/dagger.git'
112          developerConnection = 'scm:git:ssh://git@github.com/google/dagger.git'
113          tag = 'HEAD'
114        }
115        issueManagement {
116          system = 'GitHub Issues'
117          url = 'https://github.com/google/dagger/issues'
118        }
119        licenses {
120          license {
121            name = 'Apache 2.0'
122            url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
123          }
124        }
125        organization {
126          name = 'Google, Inc.'
127          url = 'https://www.google.com'
128        }
129        withXml {
130          def projectNode = asNode()
131          // Adds:
132          // <parent>
133          //   <groupId>org.sonatype.oss</groupId>
134          //   <artifactId>oss-parent</artifactId>
135          //   <version>7</version>
136          // </parent>
137          def parentNode = projectNode.appendNode('parent')
138          parentNode.appendNode('groupId', 'org.sonatype.oss')
139          parentNode.appendNode('artifactId', 'oss-parent')
140          parentNode.appendNode('version', '7')
141          // Adds scm->tag because for some reason the DSL API does not.
142          // <scm>
143          //   <tag>HEAD</tag>
144          // </scm>
145          projectNode.get('scm').first().appendNode('tag', 'HEAD')
146        }
147      }
148    }
149  }
150  // Publish to build output repository.
151  repositories {
152    maven {
153      url = uri("$buildDir/repo")
154    }
155  }
156}
157
158group='com.google.dagger'
159