Skip to content

Commit

Permalink
[TH2-5267] Migrated to th2 gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Smirnov-Exactpro committed Feb 18, 2025
1 parent 825a9c6 commit 8177171
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 162 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
# Enable version updates for Gradle
- package-ecosystem: "gradle"
# Look for `build.gradle` file in the `root` directory
directory: "/"
# Check for updates every day (weekdays)
schedule:
interval: "daily"
allow:
# Allow updates for Exactpro packages
- dependency-name: "com.exactpro*"
# Allow up to 10 open pull requests
open-pull-requests-limit: 10
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
name: Build and release Java distributions to sonatype.
name: Build and publish dev release jar to sonatype repository

on:
push:
branches:
- master
- version-*
paths:
- gradle.properties
on: workflow_dispatch

jobs:
build:
uses: th2-net/.github/.github/workflows/compound-java.yml@main
with:
build-target: 'Sonatype'
runsOn: ubuntu-latest
devRelease: true
createTag: true
secrets:
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
nvd-api-key: ${{ secrets.NVD_APIKEY }}
17 changes: 17 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build and publish release jar to sonatype repository

on: workflow_dispatch

jobs:
build:
uses: th2-net/.github/.github/workflows/compound-java.yml@main
with:
build-target: 'Sonatype'
devRelease: false
createTag: true
secrets:
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
nvd-api-key: ${{ secrets.NVD_APIKEY }}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: Dev build and publish Java distributions to sonatype snapshot repository
name: Build and publish jar to sonatype snapshot repository

on:
push:
branches-ignore:
- master
- version-*
- dependabot*
# paths:
# - gradle.properties
- master
- version-*
- dependabot*
paths-ignore:
- README.md

Expand All @@ -16,10 +14,9 @@ jobs:
uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main
with:
build-target: 'Sonatype'
runsOn: ubuntu-latest
secrets:
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}

nvd-api-key: ${{ secrets.NVD_APIKEY }}
4 changes: 2 additions & 2 deletions .github/workflows/ci-unwelcome-words.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jobs:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Checkout tool
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: exactpro-th2/ci-github-action
ref: master
Expand Down
158 changes: 16 additions & 142 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,163 +1,37 @@
plugins {
id 'java-library'
id 'signing'
id 'maven-publish'
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id "org.owasp.dependencycheck" version "8.1.0"
id "com.exactpro.th2.gradle.publish" version "0.1.8"
}

group = 'com.exactpro.th2'
version = release_version

ext {
sharedDir = file("${project.rootDir}/shared")
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

repositories {
mavenCentral()
configurations.all {
maven {
name 'Sonatype_snapshots'
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name 'Sonatype_releases'
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
mavenLocal()
configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
}

dependencies {
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
}

dependencyCheck {
formats=['SARIF', 'JSON', 'HTML']
failBuildOnCVSS=5

analyzers {
assemblyEnabled = false
nugetconfEnabled = false
nodeEnabled = false
}
testImplementation 'org.assertj:assertj-core:3.27.3'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.4'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.4'
}

test {
useJUnitPlatform()
}


tasks.named("jar") {
manifest {
attributes(
'Created-By': "${System.getProperty('java.version')} (${System.getProperty('java.vendor')})",
'Specification-Title': '',
'Specification-Vendor': 'Exactpro Systems LLC',
'Implementation-Title': project.archivesBaseName,
'Implementation-Vendor': 'Exactpro Systems LLC',
'Implementation-Vendor-Id': 'com.exactpro',
'Implementation-Version': project.version
)
}
}

java {
withJavadocJar()
withSourcesJar()
}

// conditionals for publications
tasks.withType(PublishToMavenRepository) {
onlyIf {
(repository == publishing.repositories.nexusRepository &&
project.hasProperty('nexus_user') &&
project.hasProperty('nexus_password') &&
project.hasProperty('nexus_url')) ||
(repository == publishing.repositories.sonatype &&
project.hasProperty('sonatypeUsername') &&
project.hasProperty('sonatypePassword')) ||
(repository == publishing.repositories.localRepo)
}
}
tasks.withType(Sign) {
onlyIf { project.hasProperty('signingKey') &&
project.hasProperty('signingPassword')
}
}
// disable running task 'initializeSonatypeStagingRepository' on a gitlab
tasks.whenTaskAdded {task ->
if(task.name.equals('initializeSonatypeStagingRepository') &&
!(project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword'))
) {
task.enabled = false
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = rootProject.name
packaging = 'jar'
description = rootProject.description
url = vcs_url
scm {
url = vcs_url
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'developer'
name = 'developer'
email = 'developer@exactpro.com'
}
}
scm {
url = vcs_url
}
}
}
}
repositories {
maven {
name = 'localRepo'
url = sharedDir
}
//Nexus repo to publish from gitlab
maven {
name = 'nexusRepository'
credentials {
username = project.findProperty('nexus_user')
password = project.findProperty('nexus_password')
}
url = project.findProperty('nexus_url')
}
}
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}

signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}

clean {
delete sharedDir
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencyLocking {
lockAllConfigurations()
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 8177171

Please sign in to comment.