Skip to content

Commit

Permalink
Refactoring into two subprojects, so that the dsl can be developed in…
Browse files Browse the repository at this point in the history
… isolated and with greater speed
  • Loading branch information
Justin Ryan committed Nov 13, 2012
1 parent e0f5f7c commit e215e35
Show file tree
Hide file tree
Showing 65 changed files with 105 additions and 66 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ gradle-app.setting
*~
*.bak
/local*
/build
build
/out


#Jenkins specific out
*.hpi
80 changes: 28 additions & 52 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,66 +1,42 @@
buildscript {
repositories {
maven {
name 'jenkins-ci-plugins'
url('http://maven.jenkins-ci.org/content/repositories/releases')

allprojects {
buildscript {
repositories {
mavenCentral()
}
}
repositories {
mavenCentral()
}
dependencies { classpath('org.jenkins-ci.tools:gradle-jpi-plugin:0.4.0') }
}
apply plugin: 'jpi'

repositories {
maven {
name 'jenkin-ci'
url 'http://maven.jenkins-ci.org/content/repositories/releases'
subprojects {
apply plugin: 'groovy'
dependencies {
//groovy localGroovy() // Can't guarantee 1.8.6
groovy 'org.codehaus.groovy:groovy-all:1.8.6'
compile 'xmlunit:xmlunit:1.1'
compile 'com.google.guava:guava:13.0.1'
testCompile 'org.spockframework:spock-core:0.6-groovy-1.8'
testCompile 'junit:junit:4.10'
}
test {
useJUnit() // Causes "failed to create temp file to extract class from jar into"
}
mavenCentral()
}

configurations.testCompile.exclude group: 'org.jenkins-ci.modules', module:'instance-identity'
configurations.testCompile.exclude group: 'org.jenkins-ci.modules', module:'ssh-cli-auth'

dependencies {
//groovy localGroovy() // Can't guarantee 1.8.6
groovy 'org.codehaus.groovy:groovy-all:1.8.6'
compile 'xmlunit:xmlunit:1.1'
testCompile 'org.spockframework:spock-core:0.6-groovy-1.8'
testCompile 'junit:junit:4.10'
}

test {
useJUnit() // Causes "failed to create temp file to extract class from jar into"
}

group = "org.jenkinsci.plugins"
description = "This plugin allows definition of Jobs via a DSL, using existing Jobs as a template."
//archivesBaseName = "job-dsl-plugin"

jenkinsPlugin {
coreVersion = '1.456'
displayName = 'Job DSL'
url = 'https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin'
gitHubUrl = 'https://github.com/jenkinsci/job-dsl-plugin'
developers {
developer {
id 'quidryan'
name 'Justin Ryan'
email '[email protected]'
}
developer {
id 'andrewharmellaw'
name 'Andrew Harmel-Law'
email '[email protected]'
}
developer {
id 'sit'
name 'Emil Sit'
email '[email protected]'
}
task wrapper(type: Wrapper) { gradleVersion = '1.2' }

project(':job-dsl-core') {
dependencies {
}
}

task wrapper(type: Wrapper) { gradleVersion = '1.2' }

apply from: 'gradle/ide.gradle'
project(':job-dsl-plugin') {
dependencies {
compile project(':job-dsl-core')
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.5
version=1.6-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ public PrintStream getOutputStream() {
public Map<String, String> getParameters() {
return Maps.newHashMap();
}

protected void validateUpdateArgs(String jobName, String config) {
if (jobName == null || jobName.isEmpty()) throw new JobNameNotProvidedException();
if (config == null || config.isEmpty()) throw new JobConfigurationMissingException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class FileJobManagement extends AbstractJobManagement {
}

boolean createOrUpdateConfig(String jobName, String config) throws JobNameNotProvidedException, JobConfigurationMissingException {
validateUpdateArgs(jobName, config);

new File(jobName).write(config)
return true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package javaposse.jobdsl.dsl

import javaposse.jobdsl.dsl.JobManagement;
import javaposse.jobdsl.plugin.JenkinsJobManagement;
import javaposse.jobdsl.dsl.JobConfigurationNotFoundException;

import spock.lang.*
Expand All @@ -24,7 +23,7 @@ class JobManagementTest extends Specification {

def "get config - no name provided"() {
setup:
JobManagement jm = new JenkinsJobManagement()
JobManagement jm = new StringJobManagement()

when:
String xml = jm.getConfig("")
Expand Down Expand Up @@ -78,11 +77,12 @@ class JobManagementTest extends Specification {
// // Check that the new config for this job is as expected now the update was successful
// }


def "create new config - name not provided (NULL)"() {
// Should throw a "NewJobNameMissingException
setup:
setIgnoreWhitespace(Boolean.TRUE); // XMLUnit
JobManagement jm = new JenkinsJobManagement()
JobManagement jm = new StringJobManagement()

when:
jm.createOrUpdateConfig(null, updatedXml_keepDepIsTrue)
Expand All @@ -95,7 +95,7 @@ class JobManagementTest extends Specification {
// Should throw a "NewJobNameMissingException
setup:
setIgnoreWhitespace(Boolean.TRUE); // XMLUnit
JobManagement jm = new JenkinsJobManagement()
JobManagement jm = new StringJobManagement()

when:
jm.createOrUpdateConfig("", updatedXml_keepDepIsTrue)
Expand All @@ -108,7 +108,7 @@ class JobManagementTest extends Specification {
// Should throw a "NewJobNameMissingException
setup:
setIgnoreWhitespace(Boolean.TRUE); // XMLUnit
JobManagement jm = new JenkinsJobManagement()
JobManagement jm = new StringJobManagement()

when:
jm.createOrUpdateConfig("NEW-JOB-NAME", null)
Expand All @@ -121,7 +121,7 @@ class JobManagementTest extends Specification {
// Should throw a "NewJobNameMissingException
setup:
setIgnoreWhitespace(Boolean.TRUE); // XMLUnit
JobManagement jm = new JenkinsJobManagement()
JobManagement jm = new StringJobManagement()

when:
jm.createOrUpdateConfig("NEW-JOB-NAME", "")
Expand All @@ -148,4 +148,4 @@ def updatedXml_keepDepIsTrue = '''
</project>
'''

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class JobTest extends Specification {
def 'load large template from file'() {
setup:
println new File('src/test/resources').absolutePath
JobManagement jm = new FileJobManagement(new File('src/test/resources'))
Job job = new Job(jm)
Expand Down Expand Up @@ -167,4 +168,4 @@ class JobTest extends Specification {
</project>
'''

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class StringJobManagement extends AbstractJobManagement {
}

boolean createOrUpdateConfig(String jobName, String config) {
validateUpdateArgs(jobName, config);

savedConfigs[jobName] = config
return false
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions job-dsl-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
buildscript {
repositories {
maven {
name 'jenkins-ci-plugins'
url('http://maven.jenkins-ci.org/content/repositories/releases')
}
}
dependencies { classpath('org.jenkins-ci.tools:gradle-jpi-plugin:0.4.0') }
}
apply plugin: 'jpi'

repositories {
maven {
name 'jenkin-ci'
url 'http://maven.jenkins-ci.org/content/repositories/releases'
}
}

configurations.testCompile.exclude group: 'org.jenkins-ci.modules', module:'instance-identity'
configurations.testCompile.exclude group: 'org.jenkins-ci.modules', module:'ssh-cli-auth'

description = "Jenkins plugin to leverage job-dsl-core to programmatic create jobs from inside Jenkins."

jenkinsPlugin {
coreVersion = '1.456'
displayName = 'Job DSL'
url = 'https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin'
gitHubUrl = 'https://github.com/jenkinsci/job-dsl-plugin'
developers {
developer {
id 'quidryan'
name 'Justin Ryan'
email '[email protected]'
}
developer {
id 'andrewharmellaw'
name 'Andrew Harmel-Law'
email '[email protected]'
}
developer {
id 'sit'
name 'Emil Sit'
email '[email protected]'
}
}
}

//apply from: 'ide.gradle'
File renamed without changes.
2 changes: 1 addition & 1 deletion gradle/ide.gradle → job-dsl-plugin/ide.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'idea'
apply plugin: 'eclipse'

def gitIgnore = file('.gitignore').readLines()
def gitIgnore = rootProject.file('.gitignore').readLines()
def gitIgnoreDirs = gitIgnore*.trim().findAll { !it.startsWith('#') && it.endsWith('/') }

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public boolean createOrUpdateConfig(String jobName, String config) throws JobNam
LOGGER.log(Level.INFO, String.format("createOrUpdateConfig for %s", jobName));
boolean created = false;

if (jobName == null || jobName.isEmpty()) throw new JobNameNotProvidedException();
if (config == null || config.isEmpty()) throw new JobConfigurationMissingException();
validateUpdateArgs(jobName, config);

AbstractProject<?,?> project = (AbstractProject<?,?>) jenkins.getItemByFullName(jobName);
Jenkins.checkGoodName(jobName);
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rootProject.name='job-dsl-plugin'
rootProject.name='job-dsl-plugin-root'
include 'job-dsl-core', 'job-dsl-plugin'

0 comments on commit e215e35

Please sign in to comment.