Skip to content

Commit

Permalink
Gradle build updates (#17)
Browse files Browse the repository at this point in the history
* Update gradle build workflow
- Add versioning for Wowza dependencies
- Implement git-properties gradle plugin
- Add build info to jar MANIFEST.MF
- Add LICENSE.txt to jar META-INF
* Remove unused upload-artifact action from release workflow
  • Loading branch information
rogerlittin authored Sep 8, 2023
1 parent d477c25 commit 93ea51e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ jobs:
build
-Pversion=${{ github.ref_name }}
-PwseLibDir=${{ vars.WSE_HOME }}/files/lib
- uses: actions/upload-artifact@v3
with:
name: Package
path: build/libs
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The module is also able to send tracking events via a _Server Side Tag Manager_
## Build instructions
* Clone repo to local filesystem.
* Update `wseLibDir` variable in the `gradle.properties` file to point to local _Wowza Streaming Engine_ `lib` folder.
* Run `./gradlew generateJava` command to generate the `BuildProperties.java` file. This task will automatically run before each compile to regenerate the file.
* Run `./gradlew generateBuildProperties` command to generate the `BuildProperties.java` file. This task will automatically run before each compile to regenerate the file.
* Run `./gradlew build` to build the jar file.

## More resources
Expand Down
43 changes: 34 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java-library'
id 'com.gorylenko.gradle-git-properties' version '2.4.1'
}

java {
Expand All @@ -16,29 +17,53 @@ repositories {
}

dependencies {
compileOnly name: 'wms-server'
compileOnly name: 'wms-webrtc'
compileOnly 'com.wowza.wms:wms-server:4.8.22'
compileOnly 'com.wowza.wms:wms-webrtc:4.8.22'
compileOnly 'org.apache.logging.log4j:log4j-core:2.17.2'
compileOnly 'org.apache.logging.log4j:log4j-api:2.17.2'
}

tasks.register("generateJava") {
gitProperties {
extProperty = 'gitProps'
dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
dateFormatTimeZone = 'UTC'
}

generateGitProperties.outputs.upToDateWhen { false }

tasks.register('generateBuildProperties') {
dependsOn generateGitProperties
ext.outputDir = "$buildDir/generated/java"
inputs.property('version', project.version)
outputs.dir outputDir
doLast {
mkdir "$outputDir/com/wowza/wms/plugin/${projectName}"
file("$outputDir/com/wowza/wms/plugin/analytics/BuildProperties.java").text =
file("$outputDir/com/wowza/wms/plugin/${projectName}/BuildProperties.java").text =
"""|package com.wowza.wms.plugin.${projectName};
|public class BuildProperties {
| public static String getVersion() { return "${project.version}"; }
| public static String getBuildDate() { return "${-> project.ext.gitProps['git.commit.time']}"; }
| public static String getBuildRevision() { return "${-> project.ext.gitProps['git.commit.id.abbrev']}"; }
|}""".stripMargin()
}
}

compileJava.dependsOn generateJava
sourceSets.main.java.srcDir generateJava.outputDir
compileJava.dependsOn generateBuildProperties
sourceSets.main.java.srcDir generateBuildProperties.outputDir

tasks.withType(Jar).configureEach {
archiveBaseName = "wse-plugin-${projectName}"
}
jar.configure {
manifest {
attributes(
'Gradle-Version' : "Gradle ${gradle.gradleVersion}",
'Created-By' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Name' : "${project.name}",
'Build-Version' : "${project.version}",
'Build-Timestamp' : "${-> project.ext.gitProps['git.commit.time']}",
'Build-Revision' : "${-> project.ext.gitProps['git.commit.id.abbrev']}",
)
}
exclude('git.properties')
metaInf {
from files('LICENSE.txt')
}
}

0 comments on commit 93ea51e

Please sign in to comment.