Skip to content

Commit

Permalink
Finalised Banana
Browse files Browse the repository at this point in the history
  • Loading branch information
victorskl committed Mar 3, 2019
1 parent 774be05 commit 9cd0cf4
Show file tree
Hide file tree
Showing 17 changed files with 315 additions and 189 deletions.
75 changes: 59 additions & 16 deletions 07-platform-bom-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Goal
- want to release software components independent of each other, but operate like μServices fashion


---

## Maven Solution

Expand Down Expand Up @@ -65,9 +64,12 @@ mvn help:effective-pom
- https://maven.apache.org/plugins/maven-help-plugin/usage.html


---

## Gradle
## Gradle Solution

- Gradle solution involves mainly relying on its Plugin feature, i.e. very plugin opinionated!

- To contrast with Maven inheritance style, Gradle's way can be thought of it as _cross cutting_ configuration with custom plugins.

- Treat these directories as separate repos:

Expand All @@ -82,27 +84,30 @@ gradle
4 directories, 0 files
```

- Then; let plumb the `platform` and `plugin`
- Then; let plumb the `plugin`

```
rm -rf ~/.m2/repository/com/sankholin/banana/
cd gradle/banana-platform
cd gradle/banana-plug
gw clean --info
tree
gw dependencies --info
gw publishMavenPublicationToMavenLocal --info
gw publishToMavenLocal --info
ll ~/.m2/repository/com/sankholin/banana/
```

- Then; let plumb the `platform` for Maven BOM style `dependenciesManagement`

```
rm -rf ~/.m2/repository/com/sankholin/banana/
cd ../banana-plug
cd ../banana-platform
gw clean --info
tree
gw dependencies --info
gw publishMavenPublicationToMavenLocal --info
gw publishToMavenLocal --info
ll ~/.m2/repository/com/sankholin/banana/
```

- Now; we can try test `app` for those `platform` and `plugin` settings that applied
Expand All @@ -117,6 +122,9 @@ tree build
gw hello
```

### Init script

- https://docs.gradle.org/current/userguide/init_scripts.html


### Java Platform plugin
Expand All @@ -128,32 +136,67 @@ gw hello
- https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:bom_import
- https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html

### Maven publishing
### Maven Publishing plugin

- https://docs.gradle.org/current/userguide/publishing_maven.html
- https://docs.gradle.org/current/userguide/publishing_overview.html

### Init script

- https://docs.gradle.org/current/userguide/init_scripts.html
### Signing plugin

- https://docs.gradle.org/current/userguide/signing_plugin.html

### Repository

- https://docs.gradle.org/current/userguide/declaring_repositories.html
- https://docs.gradle.org/current/userguide/repository_types.html

### Credentials

- https://help.sonatype.com/repomanager2/maven-and-other-build-tools/gradle
- ...
- https://discuss.gradle.org/t/publish-to-maven-repository/26138
- https://discuss.gradle.org/t/maven-publish-and-authentication/6833
- https://discuss.gradle.org/t/need-the-gradle-script-to-publish-a-jar-in-my-project-to-a-nexus-repository/22008
- https://discuss.gradle.org/t/avoid-build-repository-credentials-in-build-gradle/25653/2
- https://stackoverflow.com/questions/12749225/where-to-put-gradle-configuration-i-e-credentials-that-should-not-be-committe


### Custom Plugins

- https://guides.gradle.org/writing-gradle-plugins/
- https://guides.gradle.org/implementing-gradle-plugins/
- ...
- https://docs.gradle.org/current/userguide/custom_plugins.html

- https://docs.gradle.org/current/userguide/java_gradle_plugin.html
- https://docs.gradle.org/current/userguide/plugins.html
- ...
- https://www.praqma.com/stories/gradle-plugin-bootstrap/
- http://blog.anorakgirl.co.uk/2014/12/gradle-and-the-parent-pom/
- https://stackoverflow.com/questions/51773218/why-does-gradle-not-look-in-the-local-maven-repository-for-plugins/51775637


### Resources

- https://stackoverflow.com/questions/9539986/how-to-share-a-common-build-gradle-via-a-repository
- https://stackoverflow.com/questions/54647730/gradle-java-platform-plugin-and-platform-definition
- https://stackoverflow.com/questions/15468109/gradle-parent-pom-like-feature
- https://discuss.gradle.org/t/support-for-gradle-parent-shared-between-projects-cached-locally/488/3
- https://discuss.gradle.org/t/can-i-publish-pom-only-artifacts-with-gradle/3760


### aalmiray's kordamp-gradle-plugins

- http://andresalmiray.com/on-joining-gradle/
- ...
- http://andresalmiray.com/the-gradle-pom/
- https://github.com/jsr377/jsr377-api
- http://andresalmiray.com/the-gradle-superpom/
- https://gist.github.com/aalmiray/037412256648f8711afa51a622e7f855
- http://andresalmiray.com/gaining-insight-into-a-gradle-build/
- ...
- https://aalmiray.github.io/kordamp-gradle-plugins/
- https://aalmiray.github.io/kordamp-gradle-plugins/api-html/index.html
- https://github.com/aalmiray/kordamp-gradle-plugins



27 changes: 4 additions & 23 deletions 07-platform-bom-build/gradle/banana-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath 'com.sankholin.banana:banana-plug:3.0.0-SNAPSHOT'
}
}

plugins {
id 'java'
// id 'org.springframework.boot' version '2.1.3.RELEASE'
// id 'com.sankholin.banana.banana-plug' version '3.0.0-SNAPSHOT'
id 'com.sankholin.banana.banana-plug' version '3.0.0-SNAPSHOT'
}

//apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.sankholin.banana.banana-plug'

group = 'com.sankholin.banana'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
jcenter()
mavenLocal()
}

dependencies {
implementation enforcedPlatform('com.sankholin.banana:banana-platform:3.0.0-SNAPSHOT')
implementation enforcedPlatform('com.sankholin.banana:banana-platform:3.0.0-SNAPSHOT')

implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-validation'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

// compileOnly 'org.projectlombok:lombok'
// annotationProcessor 'org.projectlombok:lombok'
Expand Down
5 changes: 5 additions & 0 deletions 07-platform-bom-build/gradle/banana-app/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This gradle.properties should be copied over to your ~/.gradle/gradle.properties
# And configure your environment specific setting and credentials there. Not here.
repoUrl = http://repoUrl
repoUser = repoUser
repoPass = repoPass
42 changes: 33 additions & 9 deletions 07-platform-bom-build/gradle/banana-app/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
// Resolving Custom Plugin Repositories for plugins {} DSL - but not working! So, just use buildscript {} block
// https://stackoverflow.com/questions/51773218/why-does-gradle-not-look-in-the-local-maven-repository-for-plugins/51775637
// https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories
// https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_management
// https://stackoverflow.com/questions/37285413/how-can-the-gradle-plugin-repository-be-changed
//
//pluginManagement {
// repositories {
// mavenLocal()
// gradlePluginPortal()
// }
//}
// NOTE: This could also be done globally at ~/.gradle/init.gradle. See above links.
//
// NOTE: The repoUrl property need to specify protocol handler such as 'http://repoUrl'.
// Otherwise it will fall back to 'file://' protocol and will get:
// Authentication scheme 'all'(Authentication) is not supported by protocol 'file' error.
// See
// https://stackoverflow.com/questions/43809688/authentication-error-when-publishing-from-gradle-to-nexus
//
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
jcenter()
mavenCentral()

// can resolve these variables from gradle.properties
println repoUrl
println repoUser
println repoPass

maven {
url "$repoUrl/repository/maven-public/"
name = "Banana"
credentials {
username repoUser
password repoPass
}
}

}
}

rootProject.name = 'banana-app'
81 changes: 52 additions & 29 deletions 07-platform-bom-build/gradle/banana-platform/build.gradle
Original file line number Diff line number Diff line change
@@ -1,45 +1,68 @@
plugins {
id 'java-platform'
id 'maven-publish'
id 'java-platform'
id 'maven-publish'
id 'com.diffplug.gradle.spotless' version '3.18.0'
}

repoUrl = getProperty('repoUrl')
repoUser = getProperty('repoUser')
repoPass = getProperty('repoPass')
println 'gradle.properties: ' + repoUrl + ' ' + repoUser + ' ' + repoPass

group = 'com.sankholin.banana'
version = '3.0.0-SNAPSHOT'

repositories {
jcenter()
mavenLocal()
jcenter()
mavenLocal()
}

javaPlatform {
allowDependencies()
}
javaPlatform { allowDependencies() }

dependencies {
// Inherent BOM or platform
api enforcedPlatform('org.springframework.boot:spring-boot-dependencies:2.1.3.RELEASE')

// We may also define common dependencies here, but it seems doing such way is discouraged
//api 'org.projectlombok:lombok'

constraints {
// Constraint the version on those who like to consume Banana platform or BOM
api 'com.sankholin.banana:banana-sim-core:1.1.0'
api 'com.sankholin.banana:banana-domain:3.0.0-SNAPSHOT'
api 'com.sankholin.banana:banana-service:3.0.0-SNAPSHOT'
api 'com.sankholin.banana:banana-utils:3.0.0-SNAPSHOT'

// It can be also some external libraries.
//api 'commons-httpclient:commons-httpclient:3.1'
//api 'org.apache.commons:commons-lang3:3.8.1'
//runtime 'org.postgresql:postgresql:42.2.5'
}
// Inherent Spring Boot Gradle Java Platform Plugin (aka Spring Boot BOM)
api enforcedPlatform('org.springframework.boot:spring-boot-dependencies:2.1.3.RELEASE')

// We may also define common dependencies here, but such usage is discouraged, use sparingly!
//api 'org.projectlombok:lombok'

constraints {
// Constraint the version on those who like to consume Banana platform or BOM
api 'com.sankholin.banana:banana-sim-core:1.1.0'
api 'com.sankholin.banana:banana-domain:3.0.0-SNAPSHOT'
api 'com.sankholin.banana:banana-service:3.0.0-SNAPSHOT'
api 'com.sankholin.banana:banana-utils:3.0.0-SNAPSHOT'

// It may also involve some external libraries, but do it sparingly! follows are just e.g.
//api 'commons-httpclient:commons-httpclient:3.1'
//api 'org.apache.commons:commons-lang3:3.8.1'
//runtime 'org.postgresql:postgresql:42.2.5'
}
}

publishing {
publications {
maven(MavenPublication) {
from components.javaPlatform
}
publications {
maven(MavenPublication) { from components.javaPlatform }
}
repositories {
maven {
def releasesRepoUrl = "$repoUrl/repository/maven-releases"
def snapshotsRepoUrl = "$repoUrl/repository/maven-snapshots"
url = project.hasProperty('release') ? releasesRepoUrl : snapshotsRepoUrl
credentials {
username "$repoUser"
password "$repoPass"
}
}
}
}

spotless {
groovyGradle {
target '*.gradle'
greclipse()
indentWithSpaces(2)
trimTrailingWhitespace()
endWithNewline()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Should copy this file gradle.properties over ~/.gradle/gradle.properties
repoUrl = http://repoUrl
repoUser = repoUser
repoPass = repoPass
Loading

0 comments on commit 9cd0cf4

Please sign in to comment.