Project

General

Profile

Actions

Services » History » Revision 8

« Previous | Revision 8/9 (diff) | Next »
Alexey Demakov, 12/02/2021 02:32 PM


Services

build.gradle:

plugins {
  id 'org.sonarqube' version '1.0'
}

sonarqube {
     properties {
        property 'sonar.host.url', 'http://forge.ispras.ru:9000'
        property 'sonar.jdbc.url', 'jdbc:mysql://localhost:3306/sonar'
        property 'sonar.jdbc.driverClassName', 'com.mysql.jdbc.Driver'
        property 'sonar.jdbc.username', 'sonar'
        property 'sonar.jdbc.password', 'sonar'
    }
}

build.gradle:

plugins {
  id 'net.saliman.properties' version '1.4.4'
  id 'net.researchgate.release' version '2.3.5'
}

apply plugin: 'maven-publish'

repositories {
  maven {
    url 'https://nxs.ispras.ru/repository/snapshots'
  }
  maven {
    url 'https://nxs.ispras.ru/repository/releases'
  }
  jcenter()
}

project.group = projectGroup

release {
  failOnCommitNeeded = false

  versionPatterns = [
    // Increments build number: "0.2.5-alpha-150428" => "0.2.6-alpha-150428" 
    /(^\d+\.\d+\.)(\d+)(-[^-]*)(-[^-]*$)/: 
    { Matcher m, Project p -> m.replaceAll("${ m[0][1] }${ (m[0][2] as int) + 1 }${ m[0][3] }" ) }
  ]
}

String getCurrentDateString()  {
  new SimpleDateFormat( 'yyMMdd' ).format( new Date() )
}

task unSnapshotVersion.doLast {
  def version = project.version.toString()
  version += '-' + getCurrentDateString()
   project.plugins.getPlugin( net.researchgate.release.ReleasePlugin.class )
  .updateVersionProperty( version )
}

def repoUrlStr = 'https://nxs.ispras.ru/repository/'
def repoUserStr = hasProperty('repoUser') ? repoUser : ''
def repoPasswordStr = hasProperty('repoPassword') ? repoPassword : ''

publishing {
  publications {
    maven(MavenPublication) {
      groupId projectGroup
      artifactId projectName
      version project.version

      from components.java
    }
  }
  repositories {
    maven {
      if(project.version.endsWith('-SNAPSHOT')) {
        url repoUrlStr + 'snapshots'
      } else {
        url repoUrlStr + 'releases'
      }
      credentials {
        username repoUserStr
        password repoPasswordStr
      }
      authentication {
        basic(BasicAuthentication)
      }
    }
  }
}

afterReleaseBuild.dependsOn publish

gradle.properties:

projectGroup=...
projectName=..
# gradle-release-plugin restriction: use only '=' as separator
version=...

gradle-local.properties:

repoUser=...
repoPassword=...

.gitignore:

gradle-local.properties

settings.gradle:

rootProject.name = projectName

Updated by Alexey Demakov about 3 years ago · 9 revisions