Add the files that were accidentally excluded by .gitignore
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@
|
||||
.settings
|
||||
bin
|
||||
build
|
||||
!buildSrc/src/main/groovy/org/springframework/restdocs/build/
|
||||
target
|
||||
.idea
|
||||
*.iml
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.build
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.Exec
|
||||
import org.gradle.api.tasks.GradleBuild
|
||||
|
||||
public class SampleBuildConfigurer {
|
||||
|
||||
private final String name
|
||||
|
||||
private String workingDir
|
||||
|
||||
SampleBuildConfigurer(String name) {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
void workingDir(String workingDir) {
|
||||
this.workingDir = workingDir
|
||||
}
|
||||
|
||||
Task createTask(Project project, Object... dependencies) {
|
||||
Task mavenBuild = mavenBuild(project, dependencies)
|
||||
Task gradleBuild = gradleBuild(project, dependencies)
|
||||
Task sampleBuild = project.tasks.create name
|
||||
sampleBuild.description = "Builds the ${name} sample"
|
||||
sampleBuild.group = "Build"
|
||||
sampleBuild.dependsOn mavenBuild, gradleBuild
|
||||
return sampleBuild
|
||||
}
|
||||
|
||||
private Task mavenBuild(Project project, Object... dependencies) {
|
||||
Task mavenBuild = project.tasks.create("${name}Maven", Exec)
|
||||
mavenBuild.description = "Builds the ${name} sample with Maven"
|
||||
mavenBuild.group = "Build"
|
||||
mavenBuild.workingDir = this.workingDir
|
||||
String suffix = File.separatorChar == '/' ? '' : '.bat'
|
||||
mavenBuild.commandLine = [System.env.MAVEN_HOME ?
|
||||
"${System.env.MAVEN_HOME}/bin/mvn${suffix}" : "mvn${suffix}",
|
||||
'clean', 'package']
|
||||
mavenBuild.dependsOn dependencies
|
||||
return mavenBuild
|
||||
}
|
||||
|
||||
private Task gradleBuild(Project project, Object... dependencies) {
|
||||
Task gradleBuild = project.tasks.create("${name}Gradle", GradleBuild)
|
||||
gradleBuild.description = "Builds the ${name} sample with Gradle"
|
||||
gradleBuild.group = "Build"
|
||||
gradleBuild.dir = this.workingDir
|
||||
gradleBuild.tasks = ['clean', 'build']
|
||||
gradleBuild.dependsOn dependencies
|
||||
return gradleBuild
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.build
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
|
||||
public class SamplesExtension {
|
||||
|
||||
Project Project
|
||||
|
||||
Task buildSamplesTask
|
||||
|
||||
Object[] dependencies = []
|
||||
|
||||
SamplesExtension(Project project, Task buildSamplesTask) {
|
||||
this.project = project
|
||||
this.buildSamplesTask = buildSamplesTask
|
||||
}
|
||||
|
||||
void dependOn(Object... paths) {
|
||||
this.dependencies += paths
|
||||
}
|
||||
|
||||
def methodMissing(String name, args) {
|
||||
SampleBuildConfigurer configurer = new SampleBuildConfigurer(name)
|
||||
Closure closure = args[0]
|
||||
closure.delegate = configurer
|
||||
closure.resolveStrategy = Closure.DELEGATE_FIRST
|
||||
closure.call()
|
||||
Task task = configurer.createTask(this.project, this.dependencies)
|
||||
this.buildSamplesTask.dependsOn task
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.build
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
public class SamplesPlugin implements Plugin<Project> {
|
||||
|
||||
public void apply(Project project) {
|
||||
def buildSamplesTask = project.tasks.create('buildSamples')
|
||||
buildSamplesTask.description = 'Builds the configured samples'
|
||||
buildSamplesTask.group = 'Build'
|
||||
project.extensions.create('samples', SamplesExtension, project, buildSamplesTask)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user