Skip to content

Commit

Permalink
Merge branch '3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
at055612 committed Apr 23, 2021
2 parents 96e6e11 + 00aa033 commit da90392
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 181 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ env:
#travis encrypt -r gchq/event-logging GH_USER_AND_TOKEN="<github personal access token>"
#Required for curling the gh api to get the source of the latest event-logging release
#- secure: "TOKbp0kSCBHm6xZHpmj28ZUPC4LpbZItn15Dcyk8sQ9EcYkFdwGEpD/qqkdA+9+GRCFIBmfvfHE1D5qKWICze5IYDgAgAabaDG3zygQ/W7WAyvVSO+4go6ZTZAhm/I/vJ6cwub47aYeV+OO4g+lZcTkWJpwBdJxRsXXFCXU5VRSoBc2hn2wUZuMpdyOpLb6Gs9QpJSnpRbOcXNIupJEc9t1LoO8dvXyJEL4sYLD1YiFammdDW+q/deaevTUJrsvXs1E8lSjyf/qZsUrJqYyzrnV2c2dPb/i/z2QYajPuJv5BlCjVFIROPV+JLepDDAMZGsjaXSNl8AxhYF2lXnQoTMCK8fkaINh2opGwhp7ksOXbpUM5B/x6bORl2wou75dsboMmzycQ08NlwzBrVZ7Lv33a3j02G5cwXKxkoP07VLixqaheOsEEJUINjQNrOuopqQA9v3jBecOBXIPs/SfJCTbu1/s9lFV9Vj5Lghn1VoHoG3n9dS9xPy9BDAf1dJCNNpfL+hDtVA9kx7haZ5Az2ueBMnrRF8TZJizyKvlK+EbXYayTGyxgNlHb6cUuQY0FcFzNnGPcxCvOaw0DW2gicFt1Flz7DYtjdj0037ExSIIm7EA1i9ucP5p/U5JASM66glE5IvnCREMzVZXxflhhEUUqbQ3lexvcZMoIgAl4ink="
# - secure: "Dj0AtkItxitrOijaZc/STz/3oUyGBNaB6k3yhgZI3Fw2MDHqqV073nr5xWPawrP2AyQmRE8zRgrvLH7ZpjBcQiJnC2qYBho8Ap5ZpwtQJ6XMpPvKhlG9mXl8CQ31n0gukxJj3jSJn/+R3MPNYPxCUcQ87wOMnveY+0bJhWpfbsJKN/2OMpIc2yie2MUcJ9OpzeSfx/LekxZsTsNai6gMwB6l4l44gB2sBRPL5I3a6UFQHNS1+Z5qrlYraS2KvL2X20nfGG2SpbVfaJneNqISjPUKIsNfR1LYre/nJDSWxCpYjZfuqt6OoH9yUg/jmmKt6Y3+mF4x8/GavOs76ImBeaqBWX/esuyAQEOCfW2pcv2r6EdpGA9BQMCOi1SoEAiJC2kND4Sy+HtEkZ0xVBrAvFT/2v1F5BPu9POzsfw55R5RbwDrBO+N4zMaPtxlo7eUEJ+vPKxOgVJrU9qEIR/GEnwv3z5FXT1YxkmksWjxuXLxZlCO0NHYfB4uwdogmhD9B8dk+ZeF1fee7U088ytsvAk89cQde0CZm9n4by98gwmcopUzyQSuYaxhQHoI9sV9hCaFNwlMXwd39vO8Zbi6Wvf2upAzkgDBwG0SWMDFXppcfT7zxcYQMlouDsFpDLXqnEYTdqEJtSgSLoMCq+LXITzc+FaKu8I127USQIcikwY="



install: echo "skip 'gradle assemble' step to speed up build"

Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]


## [v5.0-beta.16_schema-v4.0-beta.3] - 2021-04-23

* Change maven coordinates to `uk.gov.gchq.eventlogging:event-logging` and publish on maven central instead of bintray.


## [v5.0-beta.15_schema-v4.0-beta.3] - 2021-04-08

* Fix build number.
Expand Down Expand Up @@ -191,7 +196,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [v3.1.0] - 2017-04-05
Intial open source release

[Unreleased]: https://github.com/gchq/event-logging/compare/v5.0-beta.15_schema-v4.0-beta.3...HEAD
[Unreleased]: https://github.com/gchq/event-logging/compare/v5.0-beta.16_schema-v4.0-beta.3...HEAD
[v5.0-beta.16_schema-v4.0-beta.3]: https://github.com/gchq/event-logging/compare/v5.0-beta.15_schema-v4.0-beta.1...v5.0-beta.16_schema-v4.0-beta.3
[v5.0-beta.15_schema-v4.0-beta.3]: https://github.com/gchq/event-logging/compare/v5.0-beta.14_schema-v4.0-beta.1...v5.0-beta.15_schema-v4.0-beta.3
[v5.0-beta.14_schema-v4.0-beta.1]: https://github.com/gchq/event-logging/compare/v5.0-beta.13_schema-v4.0-beta.1...v5.0-beta.14_schema-v4.0-beta.1
[v5.0-beta.13_schema-v4.0-beta.1]: https://github.com/gchq/event-logging/compare/v5.0-beta.12_schema-v4.0-beta.1...v5.0-beta.13_schema-v4.0-beta.1
Expand Down
151 changes: 98 additions & 53 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,51 @@ import java.util.regex.Pattern
buildscript {
repositories {
mavenLocal()
jcenter()
maven { url "https://dl.bintray.com/stroom/stroom" }
mavenCentral()
}
dependencies {
// A fork of https://github.com/wfhartford/gradle-dependency-analyze that works with Java 10
//classpath 'stroom:gradle-dependency-analyze:v2.2.2'
classpath 'ca.cutterslade.gradle:gradle-dependency-analyze:1.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
//classpath "org.javamodularity:moduleplugin:1.6.0"
classpath group: 'ca.cutterslade.gradle', name: 'gradle-dependency-analyze', version: '1.5.2'
}
}

plugins {
//plugin for downloading content from the 'net
id "de.undercouch.download" version "3.4.3"

id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
//plugin for producing a tree of task dependencies, run task 'taskTree'
//id "com.dorongold.task-tree" version "1.3"
id "com.dorongold.task-tree" version "1.5"
id "signing"
id "maven-publish"
}

//must be applied to all projects including root
apply plugin: 'ca.cutterslade.analyze'
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply plugin: 'maven-publish'

ext.isPropertySet = { propName ->
if (!project.hasProperty(propName)) {
return false
} else {
def prop = project.getProperty(propName)
return (prop != "unspecified" && (prop != "" || prop != null))
}
}

ext.ensurePropertyIsSet = { propName ->
if (!isPropertySet(propName)) {
throw new GradleException(
"Expecting project property [${propName}] or env var [ORG_GRADLE_PROJECT_${propName}] to be set.")
}
}

//if the project has a value for the passed property (i.e from the cmd line via -PpropName=xxx)
//use that, else use a default value
ext.getPropertyOrDefault = { propName, defaultValue ->
ext.getPropertyOrDefault = { propName, defaultValue ->
def val;
if (project.hasProperty(propName) && project.getProperty(propName) != "unspecified" && project.getProperty(propName) != "") {
if (isPropertySet(propName)) {
val = project.getProperty(propName)
println "Using property [$propName] with value [$val]"
println "Getting property [$propName] with value [$val]"
} else {
val = defaultValue
println "Property [$propName] has no value, using default value [$val]"
Expand All @@ -55,20 +70,39 @@ def eventLoggingSchemaVer = "v4.0-beta.3"


// Set this to the last release of this repo on this branch, or earlier branches
// It is used to diff the current jaxb code against the last release
// It is used to diff the current jaxb code against the last release so you can
// see if/how the java model has changed following schema changes or changes
// to the jaxb code generation.
// *****************************************************************************
ext.previousReleaseVersion = "v5.0-beta.13_schema-v4.0-beta.1"
ext.previousReleaseVersion = "v5.0-beta.15_schema-v4.0-beta.3"
// *****************************************************************************




def VERSION_PATTERN = /^v[0-9a-zA-Z\.-]+_schema-(v[0-9a-zA-Z\.-]+)$/
def VERSION_PATTERN = /^(?:v[0-9.]+(?:-(?:beta|alpha)[0-9.]+)?_)?schema-(v[0-9.]+(?:-(?:beta|alpha)[0-9.]+)?)(-SNAPSHOT)?$/
def CHANGE_LOG_FILENAME = "CHANGELOG.md"
def projectGroup = "event-logging"
def projectVersion = getPropertyOrDefault('version', "SNAPSHOT_schema-${eventLoggingSchemaVer}")
def projectVersion = getPropertyOrDefault('version', "schema-${eventLoggingSchemaVer}-SNAPSHOT")
def eventLoggingSchemaMajorVer = getMajorVersion(eventLoggingSchemaVer)
def combinedVersion = "${projectVersion}"

ext.isReleaseBuild = !projectVersion.endsWith("SNAPSHOT")

// We don't want the 'v' prefix on version numbers in maven
ext.projectVersionForMaven = projectVersion.replaceFirst(/^v/, "")

if (isReleaseBuild) {
println "This is a release build for maven version [${projectVersionForMaven}]"
// Ensure the various props are set for signing and publishing to sonatype

// The username for Sonatype OSSRH Jira account
ensurePropertyIsSet("sonatypeUsername")
// The password for Sonatype OSSRH Jira account
ensurePropertyIsSet("sonatypePassword")
// The GPG2 secret key in ascii armour format, base64 encoded
ensurePropertyIsSet("signingKey")
// The password for the GPG2 secret key
ensurePropertyIsSet("signingPassword")
}

if (!(projectVersion =~ /^SNAPSHOT\.*/)) {
//Ensure the version string looks a bit like v1.2.3_schema-v4.5.6
Expand All @@ -78,19 +112,20 @@ if (!(projectVersion =~ /^SNAPSHOT\.*/)) {

//Ensure the schema part of the combined version string matches eventLoggingSchemaVer
//This makes sure we don't tag as schema vX when the jar is built with schema vY
def matcher = (combinedVersion =~ VERSION_PATTERN)
def matcher = (projectVersion =~ VERSION_PATTERN)
def schemaVerFromProjectVer = matcher[0][1]
if (schemaVerFromProjectVer != eventLoggingSchemaVer) {
throw new GradleException("eventLoggingSchemaVer [${eventLoggingSchemaVer}] does not match schema version part [${schemaVerFromProjectVer}] of [${combinedVersion}]")
throw new GradleException("eventLoggingSchemaVer [${eventLoggingSchemaVer}] does not match schema version part [${schemaVerFromProjectVer}] of [${projectVersion}]")
}

//This is versioned build so ensure the version is in the CHANGELOG
def changeLogFile = new File(CHANGE_LOG_FILENAME)
def pattern = Pattern.compile(combinedVersion, Pattern.LITERAL)
def pattern = Pattern.compile(projectVersion, Pattern.LITERAL)

if (!changeLogFile.getText("UTF-8").find(pattern)) {
throw new GradleException("This is a versioned build, cannot find string \"${pattern.toString()}\" in file ${CHANGE_LOG_FILENAME}, add the new version to the change log")
}
// TODO commented for testing
//if (!changeLogFile.getText("UTF-8").find(pattern)) {
//throw new GradleException("This is a versioned build, cannot find string \"${pattern.toString()}\" in file ${CHANGE_LOG_FILENAME}, add the new version to the change log")
//}
}

//The XML Schema to use as the basis for generating the event-logging jaxb library code
Expand All @@ -109,17 +144,16 @@ if (!eventLoggingSchemaFilePath.isEmpty()) {
println "Setting eventLoggingSchemaFilePath to ${ext.eventLoggingSchemaFilePath}"
}

println "Using project version: $projectVersion"
println "Using schema version: $eventLoggingSchemaVer"
println "Using combined version: $combinedVersion"
println "Using namespace version: $eventLoggingSchemaMajorVer"
println "Using schema url: $eventLoggingSchemaUrl"
println "Using schema file path: $eventLoggingSchemaFilePath"
println "Using project version: $projectVersion"
println "Using project version (maven): ${projectVersionForMaven}"
println "Using schema version: ${eventLoggingSchemaVer}"
println "Using namespace version: ${eventLoggingSchemaMajorVer}"
println "Using schema url: ${eventLoggingSchemaUrl}"
println "Using schema file path: $eventLoggingSchemaFilePath"

ext.versions = [
//------event-logging--------------
eventLogging : projectVersion,
eventLoggingAndSchema: combinedVersion,
eventLogging : projectVersionForMaven,

//------------3rd-party------------
assertj : '3.10.0',
Expand All @@ -136,14 +170,12 @@ ext.versions = [
]

allprojects {
apply plugin: 'maven'

group "$projectGroup"
version "$projectVersion"
group "uk.gov.gchq.eventlogging" // no spaces as java pkg name convention
version projectVersionForMaven
}

subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'ca.cutterslade.analyze'
apply plugin: 'idea'
//apply plugin: "org.javamodularity.moduleplugin"
Expand All @@ -153,26 +185,26 @@ subprojects {

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

configurations {
//configurations {

all {
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "log4j", module: "log4j"
//all {
//exclude group: "org.slf4j", module: "slf4j-log4j12"
//exclude group: "log4j", module: "log4j"

resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'log4j') {
details.useTarget "org.slf4j:log4j-over-slf4j:$versions.slf4j"
}
}
resolutionStrategy {
forcedModules = [
]
}
}
}
//resolutionStrategy.eachDependency { DependencyResolveDetails details ->
//if (details.requested.name == 'log4j') {
//details.useTarget "org.slf4j:log4j-over-slf4j:$versions.slf4j"
//}
//}
//resolutionStrategy {
//forcedModules = [
//]
//}
//}
//}

test {
// Needed for junit 5
Expand Down Expand Up @@ -247,4 +279,17 @@ subprojects {
}


// Uses sonotypeUsername and sonotypePassword
// This needs to be in the root project
// See https://github.com/rwinch/gradle-publish-ossrh-sample
// Also https://github.com/kit-data-manager/nexus-publish-example
nexusPublishing {
repositories {
sonatype() //sonatypeUsername and sonatypePassword properties are used automatically
}
// these are not strictly required. The default timeouts are set to 1 minute. But Sonatype can be really slow.
// If you get the error "java.net.SocketTimeoutException: timeout", these lines will help.
connectTimeout = Duration.ofMinutes(3)
clientTimeout = Duration.ofMinutes(3)
}

22 changes: 12 additions & 10 deletions diffAgainstLatestRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ popd() {
main() {
#Check script arguments
if [ "$#" -ne 2 ] || ! [ -d "$1" ]; then
echo "${RED}INVALID ARGS!${NC}"
echo "${GREEN}Usage: $0 workingDir previousVersionTag${NC}"
echo "${GREEN}e.g : $0 event-logging-api/build v3.2.3_schema-v3.2.4${NC}"
echo -e "${RED}INVALID ARGS!${NC}"
echo -e "${GREEN}Usage: $0 workingDir previousVersionTag${NC}"
echo -e "${GREEN}e.g : $0 event-logging-api/build v3.2.3_schema-v3.2.4${NC}"

echo "Where workingDir normally event-logging-api/build"
echo -e "Where workingDir normally is event-logging-api/build"
exit 1
fi

local workingDir=${1}
local prevVersionTag="${2}"
echo "workingDir=${workingDir}"
echo -e "${BLUE}Working directory: ${YELLOW}${workingDir}${NC}"

echo "Comparing current JAXB code to release ${prevVersionTag}"
echo -e "${BLUE}Comparing current JAXB code to release:" \
"${YELLOW}${prevVersionTag}${NC}"

# GITHUB_TOKEN decalred in travis settings UI
# DO NOT echo the token!
Expand All @@ -47,8 +48,8 @@ main() {
local apiUrl="${API_URL_BASE}/${prevVersionTag}"
local prevVersionJar="event-logging-${prevVersionTag}-sources.jar"

echo "Using API URL: ${apiUrl}"
echo "Searching for file: ${prevVersionJar}"
echo -e "${BLUE}Using API URL: ${YELLOW}${apiUrl}${NC}"
echo -e "${BLUE}Searching for file: ${YELLOW}${prevVersionJar}${NC}"

local jqScript=".assets[]
| select( .name
Expand Down Expand Up @@ -95,7 +96,8 @@ main() {
rm event-logging*.jar
popd

echo -e "${BLUE}Comparing the source to the latested released version${NC}"
echo -e "${BLUE}Comparing the source to version" \
"${YELLOW}${prevVersionTag}${NC}"

diff -r old/ new/ > source.diff || true

Expand All @@ -109,7 +111,7 @@ main() {
echo
echo -e "${BLUE}$PWD/source.diff${NC}"

echo "The nature of the changes will determine whether the next release" \
echo -e "The nature of the changes will determine whether the next release" \
"is major/minor/patch or may indicate a bad change to the schema"
else
echo -e "\n${GREEN}Source is identical to ${YELLOW}${sourcesJarUrl}${NC}"
Expand Down
Loading

0 comments on commit da90392

Please sign in to comment.