Skip to content

Commit

Permalink
add composer gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
akolomentsev committed Apr 20, 2018
1 parent 83e4c7a commit 5f5c6db
Show file tree
Hide file tree
Showing 27 changed files with 312 additions and 93 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ext {
pckg = group
pckgDir = pckg.replace('.', '/')
examples = container(Object)
publishingProjects = container(Project)
}

task generateCode {
Expand Down Expand Up @@ -189,7 +190,8 @@ subprojects {
}
}

def publishingProjects = [
publishingProjects += [
":gradle-composer-plugin",
":composer",
":mods",
":mods-suite",
Expand Down
5 changes: 5 additions & 0 deletions codegen/utils/src/com/satori/codegen/utils/ICodeFormatter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ interface ICodeFormatter {
fun className(name: String) = name.pascal()
fun getterName(name: String) = "get${name.pascal()}"
fun setterName(name: String) = "set${name.pascal()}"
fun camel(name: String) = name.camel()
fun pascal(name: String) = name.pascal()
fun underscore(name: String) = name.underscore(false)
fun underscore(name: String, uppercase: Boolean) = name.underscore(uppercase)
//fun elvis(name: String)
}
1 change: 1 addition & 0 deletions gradle-composer-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/meta-info/
11 changes: 11 additions & 0 deletions gradle-composer-plugin/ComposerPluginConvention.template.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// auto generated
// don't modify
package com.satori.gradle.composer.plugin

import org.gradle.api.*

open class ${model.className}(val project: Project) {
<% rootProject.publishingProjects.forEach { p->%>
fun ${codeFormatter.methodName(p.name)}() = "${p.group}:satori-${p.name}:${p.version}"
<% } %>
}
42 changes: 42 additions & 0 deletions gradle-composer-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apply from: rootProject.file('metainfo.gradle')
apply from: rootProject.file('readme.gradle')

task generateComposerPluginConvention(type: TransformTask){
description "generate meta information class"

generateCode.dependsOn it

def outputDir = file("gen")
def className = "ComposerPluginConvention"
def classFile = new File(outputDir, "$pckgDir/${className}.kt")

template file("${className}.template.kt")
output = classFile
model.className = className

inputs.file(rootProject.file("gradle.properties"))
inputs.file(template)
outputs.file(output)

project.sourceSets.main.java.srcDirs += outputDir

clean.doFirst {
delete(outputDir)
}
}

// main dependencies
dependencies {
compile project(":libs-gradle-utils")

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion"

compile gradleApi()
}

// test dependencies
dependencies {
testCompile project(':libs-testlib')
testCompile gradleTestKit()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// auto generated
// don't modify
package com.satori.gradle.composer.plugin

import org.gradle.api.*

open class ComposerPluginConvention(val project: Project) {

fun gradleComposerPlugin() = "com.satori:satori-gradle-composer-plugin:0.5.67-SNAPSHOT"

fun composer() = "com.satori:satori-composer:0.5.67-SNAPSHOT"

fun mods() = "com.satori:satori-mods:0.5.67-SNAPSHOT"

fun modsSuite() = "com.satori:satori-mods-suite:0.5.67-SNAPSHOT"

fun libsAsyncApi() = "com.satori:satori-libs-async-api:0.5.67-SNAPSHOT"

fun libsAsyncCore() = "com.satori:satori-libs-async-core:0.5.67-SNAPSHOT"

fun libsAsyncKotlin() = "com.satori:satori-libs-async-kotlin:0.5.67-SNAPSHOT"

fun libsCommonKotlin() = "com.satori:satori-libs-common-kotlin:0.5.67-SNAPSHOT"

fun libsVertxKotlin() = "com.satori:satori-libs-vertx-kotlin:0.5.67-SNAPSHOT"

fun libsGtfs() = "com.satori:satori-libs-gtfs:0.5.67-SNAPSHOT"

fun libsCompositionDrawer() = "com.satori:satori-libs-composition-drawer:0.5.67-SNAPSHOT"

fun libsGradleUtils() = "com.satori:satori-libs-gradle-utils:0.5.67-SNAPSHOT"

fun libsGradleTransform() = "com.satori:satori-libs-gradle-transform:0.5.67-SNAPSHOT"

fun libsGradleGithub() = "com.satori:satori-libs-gradle-github:0.5.67-SNAPSHOT"

fun libsGradleDocker() = "com.satori:satori-libs-gradle-docker:0.5.67-SNAPSHOT"

fun libsGradleCodegen() = "com.satori:satori-libs-gradle-codegen:0.5.67-SNAPSHOT"

fun codegenUtils() = "com.satori:satori-codegen-utils:0.5.67-SNAPSHOT"

fun codegenCodemodelDsl() = "com.satori:satori-codegen-codemodel-dsl:0.5.67-SNAPSHOT"

fun codegenMustacheBuilder() = "com.satori:satori-codegen-mustache-builder:0.5.67-SNAPSHOT"

fun codegenYamlFileMerger() = "com.satori:satori-codegen-yaml-file-merger:0.5.67-SNAPSHOT"

}
79 changes: 79 additions & 0 deletions gradle-composer-plugin/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[![Maven](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-gradle-composer-plugin.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-gradle-composer-plugin/0.5.67-SNAPSHOT/)

## Comoser Gradle plugin

defines project extensions to simplify maintaining build system

### apply plugin example

```gradle
buildscript{
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath "com.satori:satori-gradle-composer-plugin:0.5.67-SNAPSHOT"
}
}
apply plugin: "com.satori.composer"
```

### project extensions


- `gradleComposerPlugin()` - returns `"com.satori:satori-gradle-composer-plugin:0.5.67-SNAPSHOT"`

- `composer()` - returns `"com.satori:satori-composer:0.5.67-SNAPSHOT"`

- `mods()` - returns `"com.satori:satori-mods:0.5.67-SNAPSHOT"`

- `modsSuite()` - returns `"com.satori:satori-mods-suite:0.5.67-SNAPSHOT"`

- `libsAsyncApi()` - returns `"com.satori:satori-libs-async-api:0.5.67-SNAPSHOT"`

- `libsAsyncCore()` - returns `"com.satori:satori-libs-async-core:0.5.67-SNAPSHOT"`

- `libsAsyncKotlin()` - returns `"com.satori:satori-libs-async-kotlin:0.5.67-SNAPSHOT"`

- `libsCommonKotlin()` - returns `"com.satori:satori-libs-common-kotlin:0.5.67-SNAPSHOT"`

- `libsVertxKotlin()` - returns `"com.satori:satori-libs-vertx-kotlin:0.5.67-SNAPSHOT"`

- `libsGtfs()` - returns `"com.satori:satori-libs-gtfs:0.5.67-SNAPSHOT"`

- `libsCompositionDrawer()` - returns `"com.satori:satori-libs-composition-drawer:0.5.67-SNAPSHOT"`

- `libsGradleUtils()` - returns `"com.satori:satori-libs-gradle-utils:0.5.67-SNAPSHOT"`

- `libsGradleTransform()` - returns `"com.satori:satori-libs-gradle-transform:0.5.67-SNAPSHOT"`

- `libsGradleGithub()` - returns `"com.satori:satori-libs-gradle-github:0.5.67-SNAPSHOT"`

- `libsGradleDocker()` - returns `"com.satori:satori-libs-gradle-docker:0.5.67-SNAPSHOT"`

- `libsGradleCodegen()` - returns `"com.satori:satori-libs-gradle-codegen:0.5.67-SNAPSHOT"`

- `codegenUtils()` - returns `"com.satori:satori-codegen-utils:0.5.67-SNAPSHOT"`

- `codegenCodemodelDsl()` - returns `"com.satori:satori-codegen-codemodel-dsl:0.5.67-SNAPSHOT"`

- `codegenMustacheBuilder()` - returns `"com.satori:satori-codegen-mustache-builder:0.5.67-SNAPSHOT"`

- `codegenYamlFileMerger()` - returns `"com.satori:satori-codegen-yaml-file-merger:0.5.67-SNAPSHOT"`



### Maven (snapshots)
```xml
<repository>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
```
```xml
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-gradle-composer-plugin</artifactId>
<version>0.5.67-SNAPSHOT</version>
</dependency>
```
51 changes: 51 additions & 0 deletions gradle-composer-plugin/readme.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[![Maven](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-${project.name}.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-${project.name}/${project.version}/)

## Comoser Gradle plugin

defines project extensions to simplify maintaining build system

### apply plugin example

```gradle
buildscript{
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath "com.satori:satori-${project.name}:${project.version}"
}
}
apply plugin: "com.satori.composer"
```

### project extensions

<% rootProject.publishingProjects.forEach { p->%>
- `${codeFormatter.methodName(p.name)}()` - returns `"${p.group}:satori-${p.name}:${p.version}"`
<% } %>

<% if(!project.version.endsWith("-SNAPSHOT")) {%>
### Maven (releases)
```xml
<dependency>
<groupId>${project.group}</groupId>
<artifactId>satori-${project.name}</artifactId>
<version>${project.version}</version>
</dependency>
```
<% } else {%>
### Maven (snapshots)
```xml
<repository>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
```
```xml
<dependency>
<groupId>${project.group}</groupId>
<artifactId>satori-${project.name}</artifactId>
<version>${project.version}</version>
</dependency>
```
<% }%>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
implementation-class=com.satori.gradle.composer.plugin.ComposerPlugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.satori.gradle.composer.plugin

import org.gradle.api.*

open class ComposerPlugin() : Plugin<Project> {

override fun apply(project: Project) {
val conv = ComposerPluginConvention(project)
project.convention.plugins["composer"] = conv
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.satori.gradle.composer.plugin

import org.codehaus.groovy.runtime.*
import org.gradle.testfixtures.*
import org.junit.*

class ComposerPluginTests : Assert() {

@Test
public fun `validate project extentions`() {
val project = ProjectBuilder.builder().build()
project.pluginManager.apply("com.satori.composer")

assertEquals(
"com.satori:satori-composer:${MetaInfo.version}",
InvokerHelper.invokeMethod(project, "composer", null)
)
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group=com.satori
version=0.5.64-SNAPSHOT
version=0.5.67-SNAPSHOT

scaffoldingVersion=0.5.63-SNAPSHOT
scaffoldingVersion=0.5.66-SNAPSHOT

#nexusUsername=
#nexusPassword=
Expand Down
10 changes: 5 additions & 5 deletions libs/composition-drawer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ buildscript{
maven {url "https://oss.sonatype.org/content/repositories/snapshots"}
}
dependencies {
classpath "com.satori:satori-libs-composition-drawer:0.5.64-SNAPSHOT"
classpath "com.satori:satori-libs-composition-drawer:0.5.67-SNAPSHOT"
}
}
apply plugin: "com.satori.composition.drawer"
Expand All @@ -43,7 +43,7 @@ buildscript{
maven { url "https://oss.sonatype.org/content/repositories/snapshots"}
}
dependencies {
classpath "com.satori:satori-libs-composition-drawer:0.5.64-SNAPSHOT"
classpath "com.satori:satori-libs-composition-drawer:0.5.67-SNAPSHOT"
}
}
Expand Down Expand Up @@ -72,7 +72,7 @@ repositories {
configurations{compositionDrawer}
dependencies {
compositionDrawer "com.satori:satori-libs-composition-drawer:0.5.64-SNAPSHOT"
compositionDrawer "com.satori:satori-libs-composition-drawer:0.5.67-SNAPSHOT"
}
task generateCompositionDiagram(type: JavaExec) {
Expand Down Expand Up @@ -110,13 +110,13 @@ task generateCompositionDiagram(type: JavaExec) {
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-libs-composition-drawer</artifactId>
<version>0.5.64-SNAPSHOT</version>
<version>0.5.67-SNAPSHOT</version>
</dependency>
```


### Download
[satori-libs-composition-drawer.v0.5.64-SNAPSHOT.zip](https://github.com/satori-com/satori-composer/releases/download/v0.5.64-SNAPSHOT/satori-libs-composition-drawer.v0.5.64-SNAPSHOT.zip)<br/>
[satori-libs-composition-drawer.v0.5.67-SNAPSHOT.zip](https://github.com/satori-com/satori-composer/releases/download/v0.5.67-SNAPSHOT/satori-libs-composition-drawer.v0.5.67-SNAPSHOT.zip)<br/>
[or see latest releases](https://github.com/satori-com/satori-composer/releases/latest)

### Example of generated diagram
Expand Down
6 changes: 3 additions & 3 deletions libs/gradle/codegen/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Maven](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-libs-gradle-codegen.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-libs-gradle-codegen/0.5.64-SNAPSHOT/)
[![Maven](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-libs-gradle-codegen.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-libs-gradle-codegen/0.5.67-SNAPSHOT/)

## 'codegen' gradle plugin

Expand All @@ -13,7 +13,7 @@ buildscript{
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath "com.satori:satori-libs-gradle-codegen:0.5.64-SNAPSHOT"
classpath "com.satori:satori-libs-gradle-codegen:0.5.67-SNAPSHOT"
}
}
apply plugin: "com.satori.codegen"
Expand Down Expand Up @@ -122,6 +122,6 @@ task generateGraphqlClasses {
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-libs-gradle-codegen</artifactId>
<version>0.5.64-SNAPSHOT</version>
<version>0.5.67-SNAPSHOT</version>
</dependency>
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.satori.libs.gradle.codegen

import com.satori.codegen.utils.*
import com.satori.libs.gradle.utils.*
import groovy.lang.*
import org.gradle.api.*
Expand All @@ -13,6 +14,7 @@ open class CodeGenPluginConvention(val project: Project) {
val ProjectExec = ProjectExecTask::class.java
val SourceSetExec = SourceSetExecTask::class.java
val DependencyExec = DependencyExecTask::class.java
val codeFormatter = CodeFormatter

fun projectExec(name: String, closure: Closure<*>) {
projectExec(name, ConfigureUtil.configureUsing(closure))
Expand Down
Loading

0 comments on commit 5f5c6db

Please sign in to comment.