Skip to content

Commit

Permalink
Add support for build caching
Browse files Browse the repository at this point in the history
Resolves #7
  • Loading branch information
britter committed Aug 2, 2020
1 parent d8ae1b9 commit f0a1ce8
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
= Release History

== 0.3.1

Release date: TBA

=== New Features

* Build cache support ({gh-issue}7[#7])

== 0.3.0

Release date: 2020-08-02
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ import org.codehaus.plexus.velocity.VelocityComponent
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.*
import java.util.*

@CacheableTask
abstract class GenerateHelpMojoSourcesTask : AbstractMavenPluginDevelopmentTask() {

@get:OutputDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.the
import java.io.File

@CacheableTask
abstract class GenerateMavenPluginDescriptorTask : AbstractMavenPluginDevelopmentTask() {

@get:Input
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2020 Benedikt Ritter
*
* 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 de.benediktritter.maven.plugin.development

import org.gradle.testkit.runner.TaskOutcome

class BuildCachingFuncTest extends AbstractPluginFuncTest {

def "supports build caching"() {
given:
javaMojo()
buildFile << "mavenPlugin.helpMojoPackage.set('org.example.help')"

and:
run("build", "--build-cache")

when:
buildDir.deleteDir()

and:
def result = run("build", "--build-cache")

then:
result.task(":generateMavenPluginHelpMojoSources").outcome == TaskOutcome.FROM_CACHE
result.task(":generateMavenPluginDescriptor").outcome == TaskOutcome.FROM_CACHE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ trait TestProject {
file("settings.gradle")
}

File getBuildDir() {
file("build")
}

File getBuildFile() {
file("build.gradle")
}
Expand Down

0 comments on commit f0a1ce8

Please sign in to comment.