Skip to content

Commit

Permalink
[BUILD] Use custom gradle plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
m273d15 committed Oct 14, 2019
1 parent 05746bb commit dcaff4f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 345 deletions.
61 changes: 12 additions & 49 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,16 @@ buildscript
}

plugins {
id "de.monkeyworks.buildmonkey.mavenizer.MavenizerPlugin" version "0.4.2"
id 'com.gradle.build-scan' version '2.4.1'
}

// avoid that the buildmonkey plugin triggers verbose ant logging
ant.lifecycleLogLevel = "ERROR"

// Use gradle scan plugin and service in order to visualize build/test failures
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishOnFailure()
}

// Configuration that leads to the conversion of the eclipse home dir
// (which is also a P2 repository) to a maven repository.
mavenize {
mavenizeTask {
useP2MirrorOutput = false
sourceP2Repository = System.getenv('ECLIPSE_HOME')
targetDir = rootProject.file('build/maven')
groupId = 'eclipse-deps'
}
}

// Adjust Intellij module configuration for all sub-projects
configure(subprojects) {projectToConf->
Expand All @@ -47,21 +33,16 @@ configure(subprojects) {projectToConf->


ext.projectsToConfigure = subprojects - project(':saros.picocontainer')

// Configurations that are specific to all subprojects
configure(projectsToConfigure) { projectToConf ->

apply plugin: 'eclipse'
apply plugin: 'java' // default java build plugin
apply plugin: 'jacoco' // code coverage tool
apply plugin: 'saros.gradle.eclipse.plugin'

repositories {
// general purpose repository
mavenCentral()
// repositories for specific artifacts
maven {
url 'http://maven-eclipse.github.io/maven'
content { includeGroup 'org.eclipse.swt' }
}
}

configurations {
Expand All @@ -76,6 +57,7 @@ configure(projectsToConfigure) { projectToConf ->

// Exclude test suites if property is set. Otherwise tests are executed multiple times
// in the ci server (via test class and suite).
// see gradle.properties for default values
if (projectToConf.hasProperty('skipTestSuites') && skipTestSuites.equalsIgnoreCase("true")) {
exclude '**/*TestSuite*'
}
Expand All @@ -89,6 +71,7 @@ configure(projectsToConfigure) { projectToConf ->
exclude 'saros/stf/test/stf/*'
}

// Don't execute abstract test classes
exclude '**/Abstract*'

testLogging {
Expand All @@ -99,14 +82,16 @@ configure(projectsToConfigure) { projectToConf ->

projectToConf.ext.junitVersion = 'junit:junit:4.12'
projectToConf.ext.log4jVersion = 'log4j:log4j:1.2.15'

dependencies {
compile (log4jVersion) {
projectToConf.ext.addLog4JDependency = { config ->
config.dependencies.add(dependencies.create('log4j:log4j:1.2.15') {
exclude group: 'com.sun.jmx', module: 'jmxri'
exclude group: 'com.sun.jdmk', module: 'jmxtools'
exclude group: 'javax.jms', module: 'jms'
}
})
}

dependencies {
addLog4JDependency(configurations.testConfig)
testConfig junitVersion
testConfig 'org.easymock:easymock:3.5.1'
testConfig 'org.powermock:powermock-core:2.0.0'
Expand All @@ -123,37 +108,16 @@ configure(projectsToConfigure) { projectToConf ->
from projectToConf.configurations.releaseDep
}

projectToConf.ext.eclipseHome = projectToConf.hasProperty('eclipseHome') ? eclipseHome : System.getenv('ECLIPSE_HOME')
projectToConf.ext.intellijHome = projectToConf.hasProperty('intellijHome') ? intellijHome : System.getenv('INTELLIJ_HOME')

// In order to use the relocated shadowJar of picocontainer it is necessary to replace
// the eclipse classpath entry that points to the sources of saros.picocontainer with
// the reference to the reloacted jar
eclipse.classpath {
file {
whenMerged { classpath ->
classpath.entries.removeAll{ it.path.contains('saros.picocontainer')}
}
withXml {
String jarPath = project(':saros.picocontainer').configurations.getByName('shadow').artifacts.first().file
it.asNode().appendNode('classpathentry', [kind: 'lib', path: jarPath])
.appendNode('attributes')
.appendNode('attribute', [name: 'gradle_used_by_scope', value: 'main,test'])
}
}
}
}


// remove all build dirs. The frontend package has no build directory
task cleanAll(dependsOn: projectsToConfigure.collect{":${it.name}:clean"} << 'clean')
task cleanAll(dependsOn: projectsToConfigure.collect{":${it.name}:clean"})

ext.projectsToPrepare = projectsToConfigure + project(':saros.picocontainer')
task prepareEclipse(dependsOn: projectsToPrepare.collect { [":${it.name}:cleanEclipseProject", ":${it.name}:cleanEclipseClasspath"] }.flatten() +
projectsToPrepare.collect { [":${it.name}:eclipseProject", ":${it.name}:eclipseClasspath"]}.flatten() +
['mavenizeP2Repository', 'generateLibAll'])

task prepareIntellij(dependsOn: ['mavenizeP2Repository'])
['generateLibAll'])

task cleanGenerateLibAll {
doLast {
Expand All @@ -174,7 +138,6 @@ task generateLibAll(dependsOn:['cleanGenerateLibAll',
':saros.whiteboard:generateLib'])

task sarosEclipse(type: Copy, dependsOn: [
'mavenizeP2Repository',
':saros.picocontainer:test',
':saros.core:test',
':saros.eclipse:test',
Expand Down
30 changes: 6 additions & 24 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
eclipse.project {
natures 'org.eclipse.pde.PluginNature'
sarosEclipse {
manifest = file('META-INF/MANIFEST.MF')
createBundleJar()
addPdeNature()
}

dependencies {
Expand All @@ -13,11 +15,7 @@ dependencies {
releaseDep 'com.thoughtworks.xstream:xstream:1.4.10'
releaseDep 'org.gnu.inet:libidn:1.15'

releaseDep (log4jVersion) {
exclude group: 'com.sun.jmx', module: 'jmxri'
exclude group: 'com.sun.jdmk', module: 'jmxtools'
exclude group: 'javax.jms', module: 'jms'
}
addLog4JDependency(configurations.releaseDep)
// The used version is a SNAPSHOT version which is not available!
// TODO: use real release
releaseDep files('libs/weupnp.jar')
Expand All @@ -32,27 +30,11 @@ dependencies {
sourceSets.main.java.srcDirs = ['src', 'patches']
sourceSets.test.java.srcDir 'test/junit'

jar {
manifest {
def manif = "${projectDir}/META-INF/MANIFEST.MF"
if (new File(manif).exists()) {
from (manif)
}
}

from sourceSets.main.output

// copy release dependencies into jar
into('lib') {
from configurations.getByName('releaseDep')
}
}

task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output
}

artifacts {
testing testJar
}
}
68 changes: 8 additions & 60 deletions eclipse/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
eclipse{
project {
natures 'org.eclipse.pde.PluginNature'
}
}


buildscript {
repositories {
maven {
url "http://dl.bintray.com/monkey-works/BuildMonkey"
}
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "de.monkeyworks.buildmonkey:gradle.dependency:0.4.13"
}
}

apply plugin: 'de.monkeyworks.buildmonkey.ManifestDependencyPlugin'

repositories {
maven { url rootProject.file('build/maven') }
sarosEclipse {
manifest = file('META-INF/MANIFEST.MF')
excludeManifestDependencies = ['saros.core', 'org.junit', 'org.eclipse.gef']
addPdeNature()
createBundleJar()
addDependencies()
}

sourceSets {
Expand All @@ -41,45 +22,14 @@ sourceSets {
}
}

manifestDependencies {
eclipseGroup = 'eclipse-deps'

dependencyHandling {
def ids = [:]
if (it.matches('org.junit'))
{
ids['groupId'] = 'junit'
ids['artifactId'] = 'junit'
ids['version'] = '4.11'
}
return ids
}
}

dependencies {
compile project(':saros.core')

compile project(path: ':saros.core', configuration: 'testing')
implementation project(':saros.core')

testImplementation project(path: ':saros.core', configuration: 'testing')
testImplementation configurations.testConfig
}

compileJava.dependsOn rootProject.mavenizeP2Repository

jar {
manifest {
// benutze das im Projekt vorliegende File, falls vorhanden:
def manif = "${projectDir}/META-INF/MANIFEST.MF"
if (new File(manif).exists()) {
from (manif)
}
}

from sourceSets.main.output

into('lib') {
from configurations.getByName('releaseDep')
}
into('assets') {
from 'assets'
}
Expand All @@ -101,8 +51,6 @@ task testJar(type: Jar) {
from sourceSets.test.output
}

compileJava.dependsOn rootProject.mavenizeP2Repository

artifacts {
testing testJar
}
84 changes: 5 additions & 79 deletions intellij/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.4.10"
}
}
apply plugin: 'saros.gradle.intellij.plugin'

apply plugin: 'org.jetbrains.intellij'
sarosIntellij {
localIntellijHome = intellijHome as File
intellijVersion = 'IC-2019.2.3'
}

dependencies {
compile project(':saros.core')
Expand Down Expand Up @@ -47,71 +41,3 @@ jar {
from sourceSets.main.output
}

// Intellij configuration
ext.intellijLockFileName = 'saros_sandbox.lock'
ext.intellijSandboxBaseDir = System.getenv('SAROS_INTELLIJ_SANDBOX') ?: project.buildDir
ext.intellijSandboxDir = null

intellij {
// helper functions
Closure lockSandbox = { File sandboxDir ->
sandboxDir.mkdirs()
new File(sandboxDir, intellijLockFileName).createNewFile()
}
Closure isSandboxLocked = { File sandboxDir ->
new File(sandboxDir, intellijLockFileName).exists()
}
Closure getSandboxDir = { sandboxCount ->
"${project.ext.intellijSandboxBaseDir}/idea-sandbox$sandboxCount" as File
}

// Download intellij only if the home property is not set
if (intellijHome) {
localPath = intellijHome
} else {
version = 'IC-2019.2.3'
}

// don't overwrite the version compatibility defined in the plugin.xml
updateSinceUntilBuild = false

pluginName 'Saros'

// determine new sandbox dir that is not locked
Integer sandboxCount = 1
File currentSandboxDir = getSandboxDir(sandboxCount)
while (isSandboxLocked(currentSandboxDir)) {
sandboxCount++
currentSandboxDir = getSandboxDir(sandboxCount)
}
project.ext.intellijSandboxDir = currentSandboxDir
sandboxDirectory = currentSandboxDir
}

task lockIntellijSandbox {
doLast {
File sandboxDir = project.ext.intellijSandboxDir
sandboxDir.mkdirs()
new File(sandboxDir, intellijLockFileName).createNewFile()
}
}

// remove lock file if sandbox is closed
task unlockIntellijSandbox {
doLast {
new File(project.ext.intellijSandboxDir, intellijLockFileName).delete()
}
}

runIde.dependsOn(lockIntellijSandbox)
runIde.finalizedBy(unlockIntellijSandbox)

afterEvaluate {
dependencies {
compile intellij {}
}
}

artifacts {
archives buildPlugin
}

0 comments on commit dcaff4f

Please sign in to comment.