hibernate-orm/tooling/project-template/project-template.gradle

112 lines
2.9 KiB
Groovy

import org.apache.tools.ant.filters.ReplaceTokens
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
plugins {
id 'base'
// for publishing snapshots
id 'maven-publish'
id 'org.hibernate.build.maven-repo-auth'
// publishing to BinTray
id "com.jfrog.bintray"
id "nu.studer.credentials" version "2.1"
}
// NOTE : Had trouble using the `distribution` plugin, so manually using Jar/Tar tasks
apply from: rootProject.file( 'gradle/base-information.gradle' )
ext {
processedTemplateDir = project.layout.buildDirectory.dir('resources/template')
archiveDir = project.layout.buildDirectory.dir('distributions')
}
task processTemplateResources(type:Copy) {
inputs.files( 'src/template/resources' )
outputs.dir( processedTemplateDir )
description = 'Copies the template sources into the build dir, performing some replacements'
from( 'src/template/resources' ) {
filter( ReplaceTokens, tokens: [ 'ormVersion' : project.version.toString() ] )
}
into processedTemplateDir.get().asFile
}
task templateTgz(type:Tar) {
description = 'Bundles the template project into a TGZ archive'
inputs.files( processedTemplateDir )
outputs.dir( archiveDir )
dependsOn project.tasks.processTemplateResources
compression = Compression.GZIP
from processedTemplateDir.get().asFile
destinationDirectory = archiveDir
}
task templateZip(type:Zip) {
description = 'Bundles the template project into a Zip archive'
inputs.files( processedTemplateDir )
outputs.dir( archiveDir )
dependsOn project.tasks.processTemplateResources
from processedTemplateDir.get().asFile
destinationDirectory = archiveDir
}
bintray {
user = credentials.'personal.bintray.user'
key = credentials.'personal.bintray.key'
filesSpec {
from templateTgz
from templateZip
}
pkg {
userOrg = 'hibernate'
repo = 'generic'
name = 'orm-project-template'
}
}
task assembleDist( dependsOn: [tasks.templateTgz, tasks.templateZip] )
task release( dependsOn: tasks.assembleDist )
tasks.publish {
dependsOn tasks.assembleDist
}
tasks.bintrayUpload {
dependsOn tasks.assembleDist
doFirst {
if ( credentials.'personal.bintray.user' == null ) {
throw new GradleException( "BinTray user not known, cannot perform upload" );
}
if ( credentials.'personal.bintray.key' == null ) {
throw new GradleException( "BinTray API key not known, cannot perform upload" );
}
}
}
if ( version.toString().endsWith( "-SNAPSHOT" ) ) {
tasks.bintrayUpload.enabled = false
tasks.release.dependsOn tasks.publish
}
else {
tasks.publish.enabled = false
tasks.release.dependsOn tasks.bintrayUpload
}