Skip to content
Permalink
Browse files

Initial commit

  • Loading branch information...
lacasseio committed Jun 14, 2019
0 parents commit 51dc7bead620d6445a0fcb7534ccd531d30c1f71
Showing with 1,310 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +3 −0 build.gradle.kts
  3. +37 −0 buildSrc/build.gradle.kts
  4. 0 buildSrc/settings.gradle.kts
  5. +34 −0 buildSrc/src/main/kotlin/dev/gradleplugins/AdditionalArtifactsPlugin.kt
  6. +95 −0 buildSrc/src/main/kotlin/dev/gradleplugins/IdePlugin.kt
  7. +128 −0 buildSrc/src/main/kotlin/dev/gradleplugins/PublishingPlugin.kt
  8. +63 −0 gradle-plugin-development/build.gradle.kts
  9. +9 −0 gradle-plugin-development/src/functionalTest/groovy/dev/gradleplugins/testing/SomeTest.groovy
  10. +28 −0 ...lugin-development/src/main/kotlin/dev/gradleplugins/internal/GradlePluginDevelopmentBasePlugin.kt
  11. +27 −0 ...gin-development/src/main/kotlin/dev/gradleplugins/internal/GroovyGradlePluginDevelopmentPlugin.kt
  12. +26 −0 ...lugin-development/src/main/kotlin/dev/gradleplugins/internal/JavaGradlePluginDevelopmentPlugin.kt
  13. +27 −0 ...gin-development/src/main/kotlin/dev/gradleplugins/internal/KotlinGradlePluginDevelopmentPlugin.kt
  14. +65 −0 gradle-plugin-development/src/main/kotlin/dev/gradleplugins/internal/SpockFunctionalTestingPlugin.kt
  15. +23 −0 gradle-testkit-fixtures/build.gradle.kts
  16. +96 −0 ...le-testkit-fixtures/src/main/groovy/dev/gradleplugins/test/fixtures/AbstractFunctionalSpec.groovy
  17. +160 −0 ...ixtures/src/main/groovy/dev/gradleplugins/test/fixtures/file/AbstractTestDirectoryProvider.groovy
  18. +44 −0 ...testkit-fixtures/src/main/groovy/dev/gradleplugins/test/fixtures/file/CleanupTestDirectory.groovy
  19. +60 −0 ...ixtures/src/main/groovy/dev/gradleplugins/test/fixtures/file/CleanupTestDirectoryExtension.groovy
  20. +34 −0 ...estkit-fixtures/src/main/groovy/dev/gradleplugins/test/fixtures/file/TestDirectoryProvider.groovy
  21. +47 −0 ...ixtures/src/main/groovy/dev/gradleplugins/test/fixtures/file/TestNameTestDirectoryProvider.groovy
  22. BIN gradle/wrapper/gradle-wrapper.jar
  23. +5 −0 gradle/wrapper/gradle-wrapper.properties
  24. +188 −0 gradlew
  25. +100 −0 gradlew.bat
  26. +4 −0 settings.gradle.kts
@@ -0,0 +1,7 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

.idea/
@@ -0,0 +1,3 @@
plugins {
dev.gradleplugins.ide
}
@@ -0,0 +1,37 @@
plugins {
`kotlin-dsl`
`java-gradle-plugin`
}

repositories {
jcenter()
gradlePluginPortal()
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
}

dependencies {
implementation(kotlin("gradle-plugin"))
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
implementation("com.github.jengelman.gradle.plugins:shadow:5.0.0")
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.4.2")
}

gradlePlugin {
plugins {
register("publishing-plugin") {
id = "dev.gradleplugins.publishing"
implementationClass = "dev.gradleplugins.PublishingPlugin"
}
register("ide-plugin") {
id = "dev.gradleplugins.ide"
implementationClass = "dev.gradleplugins.IdePlugin"
}
register("additional-artifacts-plugin") {
id = "dev.gradleplugins.artifacts"
implementationClass = "dev.gradleplugins.AdditionalArtifactsPlugin"
}
}
}
No changes.
@@ -0,0 +1,34 @@
package dev.gradleplugins

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.javadoc.Groovydoc
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.kotlin.dsl.*

class AdditionalArtifactsPlugin: Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
val sourceSets = the<SourceSetContainer>()
val groovydoc = tasks.named<Groovydoc>("groovydoc")
val javadoc = tasks.named<Javadoc>("javadoc")

tasks.create("sourcesJar", Jar::class) {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}

tasks.create("groovydocJar", Jar::class) {
dependsOn(groovydoc)
archiveClassifier.set("groovydoc")
from(groovydoc.get().destinationDir)
}

tasks.create("javadocJar", Jar::class) {
dependsOn(javadoc)
archiveClassifier.set("javadoc")
from(javadoc.get().destinationDir)
}
}
}
@@ -0,0 +1,95 @@
package dev.gradleplugins

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.withType
import org.gradle.plugins.ide.idea.IdeaPlugin
import org.gradle.plugins.ide.idea.model.IdeaProject
import org.jetbrains.gradle.ext.CopyrightConfiguration
import org.jetbrains.gradle.ext.ProjectSettings
import java.io.File


object Apache2Copyright {
val profileName = "ASL2"
val keyword = "Copyright"
val notice =
"""Copyright ${"$"}{today.year} the original author or 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
https://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."""
}


open class IdePlugin : Plugin<Project> {

override fun apply(project: Project): Unit = project.run {
configureIdeaForRootProject()
}

private
fun Project.configureIdeaForRootProject() {
apply(plugin = "org.jetbrains.gradle.plugin.idea-ext")
tasks.named("idea") {
doFirst {
throw RuntimeException("To import in IntelliJ, please follow the instructions here: https://github.com/gradle/gradle/blob/master/CONTRIBUTING.md#intellij")
}
}

plugins.withType<IdeaPlugin> {
with(model) {
module {
excludeDirs = excludeDirs + rootExcludeDirs
}

project {
jdkName = "8.0"
wildcards.add("?*.gradle")
vcs = "Git"

settings {
configureCopyright()
}
}
}
}
}

private
fun ProjectSettings.configureCopyright() {
copyright {
useDefault = Apache2Copyright.profileName
profiles {
create(Apache2Copyright.profileName) {
notice = Apache2Copyright.notice
keyword = Apache2Copyright.keyword
}
}
}
}
}


private
val Project.rootExcludeDirs
get() = setOf<File>(
file("intTestHomeDir"),
file("buildSrc/build"),
file("buildSrc/.gradle"))


fun IdeaProject.settings(configuration: ProjectSettings.() -> kotlin.Unit) = (this as ExtensionAware).configure(configuration)

fun ProjectSettings.copyright(configuration: CopyrightConfiguration.() -> kotlin.Unit) = (this as ExtensionAware).configure(configuration)
@@ -0,0 +1,128 @@
package dev.gradleplugins

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.BintrayPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import java.text.SimpleDateFormat
import java.util.*

class PublishingPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
applyPublishingPlugin()
configurePublishingExtension()
configureBintrayExtension()
}

private
fun Project.applyPublishingPlugin() {
apply<MavenPublishPlugin>()
apply<BintrayPlugin>()
}

private
fun Project.configurePublishingExtension() {
// val shadowJar: ShadowJar by tasks
val sourcesJar: Jar by tasks
val groovydocJar: Jar by tasks
val javadocJar: Jar by tasks

configure<PublishingExtension> {
publications {
create<MavenPublication>("mavenJava") {
// artifact(shadowJar)
artifact(sourcesJar)
artifact(groovydocJar)
artifact(javadocJar)

pom {
name.set("Gradle TestKit Fixtures")
description.set(project.provider { project.description })
url.set("https://github.com/gradle-plugins/${rootProject.name}")
inceptionYear.set("2019")

scm {
url.set("https://github.com/gradle-plugins/${rootProject.name}")
connection.set("scm:https://github.com/gradle-plugins/${rootProject.name}.git")
developerConnection.set("scm:git://github.com/gradle-plugins/${rootProject.name}.git")
}

licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}

developers {
developer {
id.set("lacasseio")
name.set("Daniel Lacasse")
url.set("https://github.com/lacasseio")
}
}
}
}
}
}
}

private
fun Project.configureBintrayExtension() {
val packageName = "dev.gradleplugins:${project.name}"

configure<BintrayExtension> {
user = resolveProperty("BINTRAY_USER", "bintrayUser")
key = resolveProperty("BINTRAY_KEY", "bintrayKey")
setPublications("mavenJava")
publish = true

pkg(closureOf<BintrayExtension.PackageConfig> {
repo = "maven"
name = packageName
desc = project.description
websiteUrl = "https://github.com/gradle-plugins/${rootProject.name}"
issueTrackerUrl = "https://github.com/gradle-plugins/${rootProject.name}/issues"
vcsUrl = "https://github.com/gradle-plugins/${rootProject.name}.git"
setLicenses("Apache-2.0")
setLabels("gradle", "gradle-plugins")
publicDownloadNumbers = true
githubRepo = "gradle-plugins/${rootProject.name}"

version(closureOf<BintrayExtension.VersionConfig> {
released = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZ").format(Date())
vcsTag = "v${project.version}"

gpg(closureOf<BintrayExtension.GpgConfig> {
sign = true
passphrase = resolveProperty("GPG_PASSPHRASE", "gpgPassphrase")
})
mavenCentralSync(closureOf<BintrayExtension.MavenCentralSyncConfig> {
sync = true
user = resolveProperty("MAVEN_CENTRAL_USER_TOKEN", "mavenCentralUserToken")
password = resolveProperty("MAVEN_CENTRAL_PASSWORD", "mavenCentralPassword")
close = "1"
})
})
})
}
}

private
fun Project.resolveProperty(envVarKey: String, projectPropKey: String): String? {
val propValue = System.getenv()[envVarKey]

if(propValue != null) {
return propValue
}

return findProperty(projectPropKey).toString()
}
}
@@ -0,0 +1,63 @@
plugins {
`kotlin-dsl`
`groovy`
`java-gradle-plugin`
id("com.gradle.plugin-publish") version("0.10.1")
}

group = "dev.gradleplugins"
version = "0.1.0-SNAPSHOT"

repositories {
jcenter()
gradlePluginPortal()
}

dependencies {
implementation(kotlin("gradle-plugin"))
implementation("org.spockframework:spock-core:1.2-groovy-2.5") {
exclude(group = "org.codehaus.groovy")
}
implementation("com.gradle.publish:plugin-publish-plugin:0.10.1")
implementation("commons-io:commons-io:2.6")
implementation(gradleTestKit())
}

gradlePlugin {
plugins {
create("javaGradlePluginDevelopment") {
id = "dev.gradleplugins.java-gradle-plugin"
implementationClass = "dev.gradleplugins.internal.JavaGradlePluginDevelopmentPlugin"
}
create("groovyGradlePluginDevelopment") {
id = "dev.gradleplugins.groovy-gradle-plugin"
implementationClass = "dev.gradleplugins.internal.GroovyGradlePluginDevelopmentPlugin"
}
create("kotlinGradlePluginDevelopment") {
id = "dev.gradleplugins.kotlin-gradle-plugin"
implementationClass = "dev.gradleplugins.internal.KotlinGradlePluginDevelopmentPlugin"
}
}
}

pluginBundle {
website = "https://gradleplugins.dev/"
vcsUrl = "https://github.com/gradle-plugins/development-gradle-plugin"
description = "Sets of highly opinionated plugins to kick start any."
tags = listOf("gradle", "gradle-plugins", "development")

plugins {
val javaGradlePluginDevelopment by existing {
// id is captured from java-gradle-plugin configuration
displayName = "Visual Studio Code Gradle Plugin"
}
val groovyGradlePluginDevelopment by existing {
// id is captured from java-gradle-plugin configuration
displayName = "Visual Studio Code Gradle Plugin"
}
val kotlinGradlePluginDevelopment by existing {
// id is captured from java-gradle-plugin configuration
displayName = "Visual Studio Code Gradle Plugin"
}
}
}
@@ -0,0 +1,9 @@
plugins {
id("dev.gradleplugins.java-gradle-plugins")
// prevent any java, java-base, groovy, kotlin, c++, c, etc plugins before or after it's opinionated so don't mess with it
// apply java-gradle-plugins
// apply publish plugin
// configure test-kit
// configure
}

0 comments on commit 51dc7be

Please sign in to comment.
You can’t perform that action at this time.