Skip to content

Commit

Permalink
Feature/automatic factory type detection (#359)
Browse files Browse the repository at this point in the history
* feat(extensible): plugin as library with automatic ModuleFactory and Tasks detection for extensibility

* ci(library maven)

* fix(gradle version)
  • Loading branch information
juancgalvis authored May 29, 2023
1 parent 8f34093 commit 8447f70
Show file tree
Hide file tree
Showing 73 changed files with 1,210 additions and 1,315 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,13 @@ jobs:
run: ./gradlew publish --info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# publish as library in maven
- name: Prepare gpg key
run: |
mkdir -p ~/.gradle/
echo "${{secrets.SIGNING_KEY_FILE}}" | base64 -d > ~/.gradle/secring.gpg
- name: Publish Libraries
run: ./gradlew publishToSonatype --debug closeAndReleaseSonatypeStagingRepository -Psigning.keyId=${{ secrets.SIGNING_KEY_ID }} -Psigning.password=${{ secrets.SIGNING_KEY_PASSWORD }} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg)
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_PASSWORD }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Gradle plugin to create a java and kotlin application based on Clean Architectur

# Plugin Implementation

To use the [plugin](https://plugins.gradle.org/plugin/co.com.bancolombia.cleanArchitecture) you need Gradle version 7.4 or later, to start add the following section into your **build.gradle** file.
To use the [plugin](https://plugins.gradle.org/plugin/co.com.bancolombia.cleanArchitecture) you need Gradle version 7.6.1 or later, to start add the following section into your **build.gradle** file.

```groovy
plugins {
Expand Down
226 changes: 156 additions & 70 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,108 +6,191 @@
* User Manual available at https://docs.gradle.org/5.6.3/userguide/custom_plugins.html
*/



plugins {
// Apply the Java Gradle plugin development plugin to add support for developing Gradle plugins
id 'java-gradle-plugin'
id 'jacoco'
id 'idea'
id 'com.gradle.plugin-publish' version '1.1.0'
id "org.sonarqube" version "3.0"
id 'com.gradle.plugin-publish' version '1.2.0'
id 'org.sonarqube' version '4.0.0.2929'
id 'com.github.sherter.google-java-format' version '0.9'
id 'maven-publish'
id "com.github.sherter.google-java-format" version "0.9"
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/bancolombia/scaffold-clean-architecture")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}

ext {
bcRepo = 'https://github.com/bancolombia/scaffold-clean-architecture'
bcPluginName = 'Scaffold Clean Architecture Bancolombia'
bcPluginDescription = 'Gradle plugin to create a clean application in Java that already works, It follows our best practices!'
}
group 'co.com.bancolombia.cleanArchitecture'

group 'co.com.bancolombia.cleanArchitecture'
version System.getProperty('version')

compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

repositories {
mavenCentral()
}

dependencies {
api 'com.github.spullara.mustache.java:compiler:0.9.10'
api 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
api 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.2'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.2'
implementation 'org.reflections:reflections:0.10.2'
api 'commons-io:commons-io:2.11.0'
api gradleApi()
testImplementation 'org.mockito:mockito-core:4.5.1'
testImplementation 'junit:junit:4.13.2'
testImplementation gradleTestKit()

compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

gradlePlugin {
// Define the plugin
plugins {
cleanArchitecture {
id = 'co.com.bancolombia.cleanArchitecture'
displayName = 'Scaffold Clean Architecture Bancolombia'
description = 'Gradle plugin to create a clean application in Java that already works, It follows our best practices!'
implementationClass = 'co.com.bancolombia.PluginClean'
if (project.hasProperty('signing.keyId')) { // publish as library in maven central
publishing {
publications {
mavenJava(MavenPublication) {
from components.java

pom {
name = bcPluginName
description = bcPluginDescription
url = bcRepo
licenses {
license {
name = "APACHE LICENSE, VERSION 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0"
distribution = "repo"
}
}
developers {
developer {
id = "santitigaga"
name = "Santiago Garcia Gil"
email = "santitigaga@hotmail.com"
}
developer {
id = "juancgalvis"
name = "Juan Carlos Galvis"
email = "juanc.galvis@outlook.com"
}
}
scm {
url = bcRepo
}
}
}
}
}

nexusPublishing {
repositories {
sonatype() {
group = "com.github.bancolombia"
}
}
}

signing {
sign(publishing.publications.mavenJava)
}

java {
withJavadocJar()
withSourcesJar()
}

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
javadoc.failOnError = false

tasks.withType(GenerateModuleMetadata) {
enabled = false
}

def signingTasks = tasks.withType(Sign)
signingTasks.forEach {project.logger.lifecycle('task sign: ' + it.name)}
tasks.withType(PublishToMavenRepository).configureEach { task ->
project.logger.lifecycle('task publish: ' + task.name)
if(task.name == 'publishMavenJavaPublicationToSonatypeRepository') {
project.logger.lifecycle('Applied to ' + task.name)
task.mustRunAfter('signMavenJavaPublication')
} else {
task.enabled = false;
}
}
} else { // publish as plugin in gradle and github
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/bancolombia/scaffold-clean-architecture")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

gradlePlugin {
// Define the plugin
website = 'https://github.com/bancolombia/scaffold-clean-architecture'
vcsUrl = 'https://github.com/bancolombia/scaffold-clean-architecture'

plugins {
cleanArchitecture {
id = 'co.com.bancolombia.cleanArchitecture'
displayName = bcPluginName
description = bcPluginDescription
implementationClass = 'co.com.bancolombia.PluginClean'
tags.set(['scaffold', 'cleanArchitecture', 'Bancolombia', 'OpenSource'])
}
}
}
}

// Add a source set for the functional test suite
sourceSets {
functionalTest {
sourceSets {
functionalTest {
}
}
}

gradlePlugin.testSourceSets(sourceSets.functionalTest)
configurations.functionalTestImplementation.extendsFrom(configurations.testImplementation)
gradlePlugin.testSourceSets(sourceSets.functionalTest)
configurations.functionalTestImplementation.extendsFrom(configurations.testImplementation)

// Add a task to run the functional tests
tasks.register('functionalTest', Test) {
description = 'Runs functional tests.'
group = 'verification'
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}
tasks.register('functionalTest', Test) {
description = 'Runs functional tests.'
group = 'verification'
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}

check {
// Run the functional tests as part of `check`
dependsOn(tasks.functionalTest)
}

check {
// Run the functional tests as part of `check`
dependsOn(tasks.functionalTest)
}

pluginBundle {
website = 'https://github.com/bancolombia/scaffold-clean-architecture'
vcsUrl = 'https://github.com/bancolombia/scaffold-clean-architecture'
tags = ['scaffold', 'cleanArchitecture', 'Bancolombia', 'OpenSource']
dependencies {
api 'com.github.spullara.mustache.java:compiler:0.9.10'
api 'com.fasterxml.jackson.core:jackson-databind:2.15.1'
api 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.1'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.1'
implementation 'org.reflections:reflections:0.10.2'
api 'commons-io:commons-io:2.12.0'
api gradleApi()
testImplementation 'org.mockito:mockito-core:4.5.1'
testImplementation 'junit:junit:4.13.2'
testImplementation gradleTestKit()

compileOnly 'org.projectlombok:lombok:1.18.26'
annotationProcessor 'org.projectlombok:lombok:1.18.26'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
}

jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled true
csv.enabled false
xml.setRequired true
xml.setOutputLocation file("${buildDir}/reports/jacoco/report.xml")
html.setRequired true
csv.setRequired false
}
}

Expand Down Expand Up @@ -147,6 +230,9 @@ tasks.register('installGitHooks', Copy) {
}

tasks.named('wrapper') {
gradleVersion = '6.9.1'
gradleVersion = '8.1.1'
}

tasks.withType(PublishToMavenRepository).configureEach {
dependsOn('signPluginMavenPublication')
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 8447f70

Please sign in to comment.