This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-generate release.yaml from subproject contents and use it in loc…
…al builds Signed-off-by: Eamonn Mansour <[email protected]>
- Loading branch information
Showing
10 changed files
with
352 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
plugins { | ||
id 'biz.aQute.bnd.builder' version '5.3.0' apply false | ||
id 'dev.galasa.githash' version '0.15.0' apply false | ||
id 'maven-publish' | ||
} | ||
|
||
version = '0.15.0' | ||
|
@@ -12,7 +13,196 @@ task clean { | |
} | ||
} | ||
|
||
//--------------------------------------------------------------- | ||
// We need to gather the release and packaging metadata from each | ||
// sub-project, to generate a release.yaml document which can act | ||
// as a manifest for this component. | ||
// | ||
// The OSGi bundles in the extensions project are all in the | ||
// 'framework' group. | ||
// | ||
// Each module is examined, and contributes it's metadata to an | ||
// overall manifest file, ready to be published to a maven | ||
// repository. | ||
// | ||
// At a later time, the OBR project will draw down the manifest | ||
// and use it to build the uber-obr. | ||
//--------------------------------------------------------------- | ||
configurations { | ||
release_metadata | ||
} | ||
|
||
def overallManifestFilePath = "$buildDir/release.yaml" | ||
def overallHeader = """# | ||
# Copyright contributors to the Galasa project | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# ----------------------------------------------------------- | ||
# | ||
# WARNING | ||
# | ||
# This file is periodically re-generated from the contents of | ||
# the repository, so don't make changes here manually please. | ||
# ----------------------------------------------------------- | ||
apiVersion: galasa.dev/v1alpha | ||
kind: Release | ||
metadata: | ||
name: galasa-release | ||
framework: | ||
bundles: | ||
""" | ||
|
||
//---------------------------------------------------------- | ||
// Flushes any existing content on the specified path, and | ||
// creates a new file, containing the header text. | ||
//---------------------------------------------------------- | ||
def prepareGeneratedFile(path, header) { | ||
// Make sure the manifest file is clean, and exists. | ||
def manifestFile = new File(path) | ||
if (manifestFile.exists()) { | ||
// File exists, delete it and create a new one. | ||
manifestFile.delete() | ||
} | ||
manifestFile.createNewFile() | ||
|
||
// Add the header to the manifest file | ||
manifestFile.append(header) | ||
} | ||
|
||
//---------------------------------------------------------- | ||
// Allow each subproject to contribute to one of the manifest | ||
// collections. | ||
//---------------------------------------------------------- | ||
task buildReleaseYaml() { | ||
println 'Building the release.yaml file...' | ||
|
||
// During execution phase, make sure the file exists. | ||
doFirst { | ||
// Make sure the build directory exists. | ||
if (!buildDir.exists()) { | ||
buildDir.mkdirs() | ||
} | ||
|
||
prepareGeneratedFile(overallManifestFilePath, overallHeader) | ||
} | ||
|
||
subprojects { | ||
ext { | ||
// the property that should be overridden in suproject's build.gradle | ||
// Each sub-project will set the values... | ||
projectName = '' | ||
includeInOBR = '' | ||
includeInMVP = '' | ||
includeInBOM = '' | ||
includeInJavadoc = '' | ||
includeInIsolated = '' | ||
includeInCodeCoverage = '' | ||
} | ||
|
||
afterEvaluate { | ||
doLast { | ||
// Some projects don't have a version property... as they are parent projects mostly. | ||
if (version != 'unspecified') { | ||
if (projectName == '') { | ||
throw new Exception("Project has no name.") | ||
} | ||
|
||
def f = new File(overallManifestFilePath) | ||
f.append("\n\n - artifact: $projectName") | ||
f.append("\n version: $version") | ||
if (includeInOBR != '') { | ||
f.append("\n obr: $includeInOBR") | ||
} | ||
if (includeInMVP != '') { | ||
f.append("\n mvp: $includeInMVP") | ||
} | ||
if (includeInBOM != '') { | ||
f.append("\n bom: $includeInBOM") | ||
} | ||
if (includeInJavadoc != '') { | ||
f.append("\n javadoc: $includeInJavadoc") | ||
} | ||
if (includeInIsolated != '') { | ||
f.append("\n isolated: $includeInIsolated") | ||
} | ||
if (includeInCodeCoverage != '') { | ||
f.append("\n codecoverage: $includeInCodeCoverage") | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Declare that the uber-manifest release.yaml file exists, and how to build it. | ||
def myReleaseYaml = artifacts.add('release_metadata', file(overallManifestFilePath)) { | ||
builtBy 'buildReleaseYaml' | ||
} | ||
|
||
subprojects { | ||
task allDeps(type: DependencyReportTask) {} | ||
} | ||
|
||
// Publish the release.yaml as a maven artifact. | ||
// Note: The maven co-ordinates are versioned using the version for this bundle. | ||
publishing { | ||
publications { | ||
|
||
// Publish the component manifest/release.yaml | ||
publishReleaseManifestYaml(MavenPublication) { | ||
artifact myReleaseYaml | ||
|
||
pom { | ||
name = "Manifest for extensions bundle versions" | ||
artifactId = "dev.galasa.extensions.manifest" | ||
groupId = 'dev.galasa' | ||
version = "0.36.0" | ||
description = "Conveys bundle version information to OBR builds." | ||
licenses { | ||
license { | ||
name = 'Eclipse Public License - v 2.0' | ||
url = 'https://www.eclipse.org/legal/epl-2.0/t' | ||
} | ||
} | ||
url = 'https://galasa.dev' | ||
developers { | ||
developer { | ||
name = 'Galasa Developer' | ||
email = '[email protected]' | ||
organization = 'IBM' | ||
organizationUrl = 'https://www.ibm.com' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:git:://github.com/galasa-dev/extensions' | ||
developerConnection = 'scm:git:git:://github.com/galasa-dev/extensions' | ||
url = 'https://github.com/galasa-dev/extensions' | ||
} | ||
issueManagement { | ||
system = 'GitHub' | ||
url = 'https://github.com/galasa-dev/projectmanagement/issues' | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
url = "$targetMaven" | ||
|
||
if ("$targetMaven".startsWith('http')) { | ||
credentials { | ||
username System.getenv('MAVENUSERNAME') | ||
password System.getenv('MAVENPASSWORD') | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.