diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index f47010f..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,70 +0,0 @@ -def server = Artifactory.server "artifactory-elyxor" -def buildInfo = Artifactory.newBuildInfo() -def rtGradle = Artifactory.newGradleBuild() - -pipeline { - agent any - - stages { - stage('Checkout') { - steps { - checkout([ - $class: 'GitSCM', - branches: scm.branches, - extensions: scm.extensions + [[$class: 'LocalBranch'], [$class: 'WipeWorkspace']], - userRemoteConfigs: scm.userRemoteConfigs - ]) - } - } - - stage('Configure Aritfactory') { - steps { - script { - rtGradle.useWrapper = true - - if(env.BRANCH_NAME == 'master') { - rtGradle.deployer repo: 'libs-release-local', server: server - rtGradle.resolver repo: 'libs-release', server: server - } else { - rtGradle.deployer repo: 'bins-snapshot-local', server: server - rtGradle.resolver repo: 'libs-snapshot', server: server - } - rtGradle.deployer.deployArtifacts = false // Disable artifacts deployment during Gradle run - } - } - } - - stage('Build') { - steps { - script { - rtGradle.run buildFile: 'build.gradle', tasks: 'build' - } - } - } - - stage('Deploy') { - steps { - script { - if (!env.BRANCH_NAME.startsWith('PR-')) { - if(env.BRANCH_NAME == 'master') { - rtGradle.run buildFile: 'build.gradle', tasks: 'setReleaseVersion artifactoryPublish', buildInfo: buildInfo - } - else { - rtGradle.run buildFile: 'build.gradle', tasks: 'artifactoryPublish', buildInfo: buildInfo - } - - rtGradle.deployer.deployArtifacts buildInfo - } - } - } - } - - stage('Publish build info') { - steps { - script { - server.publishBuildInfo buildInfo - } - } - } - } -} diff --git a/build.gradle b/build.gradle index 33a5da8..c9fe36a 100644 --- a/build.gradle +++ b/build.gradle @@ -2,16 +2,16 @@ buildscript { repositories { mavenCentral() } - dependencies { - classpath('io.swagger.codegen.v3:swagger-codegen:3.0.52') - classpath('com.github.jengelman.gradle.plugins:shadow:2.0.2') - classpath('io.swagger.codegen.v3:swagger-codegen-generators:1.0.46') - } + dependencies { + classpath('io.swagger.codegen.v3:swagger-codegen:3.0.52') + classpath('com.github.jengelman.gradle.plugins:shadow:2.0.2') + classpath('io.swagger.codegen.v3:swagger-codegen-generators:1.0.46') + } } plugins { id 'idea' - id 'java' + id 'java-library' id 'maven-publish' id 'signing' id 'org.ajoberstar.grgit' version '2.2.1' @@ -49,7 +49,7 @@ repositories { dependencies { swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen:3.0.52' - + implementation 'io.swagger.core.v3:swagger-annotations:2.2.20' implementation 'com.squareup.okhttp:okhttp:2.7.5' implementation 'com.squareup.okhttp:logging-interceptor:2.7.5' @@ -62,72 +62,74 @@ dependencies { testImplementation 'junit:junit:4.13.1' } -sourceSets { - main { - java { - srcDirs = [ codegenJavaSrcDir ] - } - resources { - srcDirs = [ codegenJavaResourceDir ] - } - } -} - -task sourceJar(type: Jar, dependsOn: classes) { - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - from javadoc.destinationDir -} - -compileJava { - options.encoding = 'UTF-8' - options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" -} - ext { startTime = new Date().format("yyy-MM-dd'T'HH:mm:ssZ") def gitRepo = Grgit.open(dir: projectDir.toString()) - gitHash = gitRepo.head().id - gitBranch = gitRepo.branch.current().name + def gitHash = gitRepo.head().id + def gitBranch = gitRepo.branch.current().name + def gitBranchFullName = gitRepo.branch.current().fullName gitRepo.close() currentJvm = Jvm.current() - if (gitBranch == 'dev') { - println 'Building master branch' - project.version = getDevVersion() + if (gitBranch.startsWith('refs/heads/release')) { // also set in + project.version = getReleaseVersion() + println 'Building release: ' + project.version + artifactoryRepo = 'libs-snapshot-local' + } else if (gitBranch == 'dev') { + println 'Building dev branch' + project.version = getDevVersion(null) artifactoryRepo = 'libs-snapshot-local' } else { - def branchVersionIdentifier = gitBranch.replaceAll("[\\W]", "_") + def branchVersionIdentifier = gitBranch.replaceAll("\\W", "_") println 'Building branch: ' + branchVersionIdentifier - project.version = getReleaseVersion(branchVersionIdentifier) - artifactoryRepo = 'libs-release-local' + project.version = getDevVersion(branchVersionIdentifier) + artifactoryRepo = 'libs-snapshot-local' } + println 'Branch Ref: ' + gitBranchFullName + ' (' + gitHash + ')' println 'Version: ' + project.version } -task setReleaseVersion { - doFirst { - project.version = project.version.replaceAll('-SNAPSHOT', '') +sourceSets { + main { + java { + srcDirs = [codegenJavaSrcDir] + } + resources { + srcDirs = [codegenJavaResourceDir] + } + } +} + +java { + withJavadocJar() + withSourcesJar() +} + +compileJava { + options.encoding = 'UTF-8' + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" +} + +jar { + manifest { + attributes( + 'Implementation-Title': project.applicationTitle, + 'Implementation-Version': project.version + ) } } -artifacts { - archives jar - archives sourceJar - archives javadocJar +tasks.named("sourcesJar") { + mustRunAfter(":generateJavaClient") } publishing { publications { - CachethqSwagger(MavenPublication) { - artifact jar - artifact sourceJar - artifact javadocJar + mavenJava(MavenPublication) { + from components.java version project.version pom.withXml { asNode().children().last() + { @@ -152,7 +154,7 @@ publishing { } } repositories { - maven { + maven { url = System.getenv('URL') + '/artifactory/' + artifactoryRepo credentials(HttpHeaderCredentials) { name = "X-JFrog-Art-API" @@ -172,7 +174,7 @@ import io.swagger.codegen.v3.ClientOpts import io.swagger.v3.parser.OpenAPIV3Parser import org.gradle.internal.jvm.Jvm -task generateJavaClient { +tasks.register('generateJavaClient') { FileTree swaggerFiles = fileTree('.') { include 'swagger.yaml' } @@ -188,10 +190,10 @@ task generateJavaClient { codegenConfig.setLibrary('okhttp-gson') def options = new ClientOpts() options.setProperties([ - 'dateLibrary': 'java8', - 'apiPackage' : 'com.elyxor.cachethq.api', - 'modelPackage': 'com.elyxor.cachethq.model', - 'sourceFolder': 'src/main/java', + 'dateLibrary' : 'java8', + 'apiPackage' : 'com.elyxor.cachethq.api', + 'modelPackage' : 'com.elyxor.cachethq.model', + 'sourceFolder' : 'src/main/java', 'interfaceOnly': 'true' ]) def openAPI = new OpenAPIV3Parser().read(file.toString(), null, null) @@ -206,7 +208,7 @@ task generateJavaClient { } } -task generatePythonClient { +tasks.register('generatePythonClient') { FileTree swaggerFiles = fileTree('.') { include 'swagger.yaml' } @@ -236,7 +238,7 @@ task generatePythonClient { } } -task copyPyProjectFile(type: Copy) { +tasks.register('copyPyProjectFile', Copy) { from "${rootProject.projectDir}/pyproject.toml" from "${rootProject.projectDir}/PYPI-README.md" into(codegenPythonDir) diff --git a/gradle.properties b/gradle.properties index 807c53a..1ebe5a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ artifactMajorVersion = 1 artifactMinorVersion = 0 -artifactPatchVersion = 7 +artifactPatchVersion = 8 applicationGroupId = com.elyxor.cachethq applicationTitle = Cachet HQ okhttp-gson API Client (java) diff --git a/pyproject.toml b/pyproject.toml index 43acfee..4dc8f8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cachethq_client" -version = "1.0.7" +version = "1.0.8" description = "A python client library for connection to a CachetHQ Server" authors = ["elyxor "] readme = "PYPI-README.md" diff --git a/versioning.gradle b/versioning.gradle index e980c4f..1645bae 100644 --- a/versioning.gradle +++ b/versioning.gradle @@ -1,13 +1,16 @@ ext { - major = project.property('artifactMajorVersion') - minor = project.property('artifactMinorVersion') - patch = project.property('artifactPatchVersion') + major = project.property('artifactMajorVersion') + minor = project.property('artifactMinorVersion') + patch = project.property('artifactPatchVersion') - getReleaseVersion = { - return major + '.' + minor + '.' + patch - } + getReleaseVersion = { + return major + '.' + minor + '.' + patch + } - getDevVersion = { branchName -> - return major + '.' + minor + '.' + patch + '-SNAPSHOT' - } + getDevVersion = { branchName -> + if (branchName) { + return major + '.' + minor + '.' + patch + "-" + branchName + } + return major + '.' + minor + '.' + patch + '-SNAPSHOT' + } }