Skip to content

Commit

Permalink
Merge pull request #45 from RedPillAnalytics/develop
Browse files Browse the repository at this point in the history
Added new functionality from Gradle-analytics.
  • Loading branch information
stewartbryson authored Nov 21, 2018
2 parents 4ee48d8 + a59e4dd commit 7c232a5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 52 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id "com.github.breadmoirai.github-release" version "2.0.1"
id 'org.unbroken-dome.test-sets' version '1.5.1'
id "com.github.ben-manes.versions" version "0.20.0"
id "com.redpillanalytics.gradle-analytics" version "1.1.9"
id "com.redpillanalytics.gradle-analytics" version "1.1.16"
}

// send analytics
Expand Down Expand Up @@ -47,6 +47,10 @@ dependencies {
compile group: 'org.slf4j', name: 'slf4j-simple', version: '+'
compile 'com.mashape.unirest:unirest-java:+'

// Gradle Analytics plugin
// It also has the Common library in it, thus the dependency here
compile "gradle.plugin.com.redpillanalytics:gradle-analytics:+"

testCompile 'org.spockframework:spock-core:1.1-groovy-2.4'
testCompile 'org.testcontainers:kafka:1.9.1'
testCompile 'org.testcontainers:spock:1.9.1'
Expand Down
8 changes: 8 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
rootProject.name = 'gradle-confluent'

if (file('../gradle-analytics').exists()) {
includeBuild('../gradle-analytics') {
dependencySubstitution {
substitute module('gradle.plugin.com.redpillanalytics:gradle-analytics') with project(':')
}
}
}
57 changes: 6 additions & 51 deletions src/main/groovy/com/redpillanalytics/gradle/ConfluentPlugin.groovy
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.redpillanalytics.gradle

import com.redpillanalytics.common.GradleUtils
import com.redpillanalytics.gradle.containers.TaskGroupContainer
import com.redpillanalytics.gradle.tasks.PipelineExecuteTask
import com.redpillanalytics.gradle.tasks.PipelineScriptTask
import com.redpillanalytics.gradle.tasks.LoadConfigTask
import groovy.util.logging.Slf4j
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.UnknownConfigurationException
import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
Expand All @@ -33,52 +33,7 @@ class ConfluentPlugin implements Plugin<Project> {

// Go look for any -P properties that have "confluent." in them
// If so... update the extension value
project.ext.properties.each { key, value ->

if (key =~ /confluent\./) {

def (extension, property) = key.toString().split(/\./)

if (extension == 'confluent' && project.confluent.hasProperty(property)) {

log.debug "Setting configuration property for extension: $extension, property: $property, value: $value"

if (project.extensions.getByName(extension)."$property" instanceof Boolean) {

project.extensions.getByName(extension)."$property" = value.toBoolean()
} else if (project.extensions.getByName(extension)."$property" instanceof Integer) {

project.extensions.getByName(extension)."$property" = value.toInteger()
} else {

project.extensions.getByName(extension)."$property" = value
}
}
}
}

def getDependency = { configuration, regexp ->

return project.configurations."$configuration".find { File file -> file.absolutePath =~ regexp }
}

def isUsableConfiguration = { configuration, regexp ->

try {

if (getDependency(configuration, regexp)) {

return true
} else {

return false
}

} catch (UnknownConfigurationException e) {

return false
}
}
GradleUtils.setParameters(project, 'confluent')

// add task to show configurations
project.task('showConfigurations') {
Expand Down Expand Up @@ -188,12 +143,12 @@ class ConfluentPlugin implements Plugin<Project> {
}

if (enablePipelines && tg.isDeployEnv) {
if (isUsableConfiguration('archives', pipelinePattern)) {
if (GradleUtils.isUsableConfiguration(project, 'archives', pipelinePattern)) {

project.task(tg.getTaskName('pipelineExtract'), type: Copy) {
group taskGroup
description = "Extract the KSQL pipeline deployment dependency (or zip file) into the deployment directory."
from project.zipTree(getDependency('archives', pipelinePattern))
from project.zipTree(GradleUtils.getDependency(project, 'archives', pipelinePattern))
into { pipelineDeployDir }

}
Expand All @@ -211,12 +166,12 @@ class ConfluentPlugin implements Plugin<Project> {
}
}

if (isUsableConfiguration('archives', functionPattern) && enableFunctions && tg.isDeployEnv) {
if (GradleUtils.isUsableConfiguration(project, 'archives', functionPattern) && enableFunctions && tg.isDeployEnv) {

project.task(tg.getTaskName('functionCopy'), type: Copy) {
group taskGroup
description = "Copy the KSQL custom function deployment dependency (or JAR file) into the deployment directory."
from getDependency('archives', functionPattern)
from GradleUtils.getDependency(project, 'archives', functionPattern)
into { functionDeployDir }
if (project.extensions.confluent.functionArtifactName) rename {
project.extensions.confluent.functionArtifactName
Expand Down

0 comments on commit 7c232a5

Please sign in to comment.