Skip to content

Commit 98d8f63

Browse files
committed
Support relative paths in git.root
1 parent 63e6024 commit 98d8f63

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy

+23
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ import org.ajoberstar.grgit.Tag
2323
import org.gradle.api.plugins.JavaPlugin
2424
import org.gradle.internal.impldep.com.amazonaws.util.Throwables
2525
import org.gradle.testkit.runner.BuildResult
26+
import org.gradle.testkit.runner.GradleRunner
2627
import org.gradle.testkit.runner.TaskOutcome
2728
import spock.lang.Ignore
2829
import spock.lang.Unroll
2930

31+
import java.nio.file.Files
32+
3033
class ReleasePluginIntegrationSpec extends GitVersioningIntegrationTestKitSpec {
3134
@Override
3235
def setupBuild() {
@@ -1281,6 +1284,26 @@ nebula.release.features.immutableSnapshot.timestampPrecision=${precision.name()}
12811284
TimestampPrecision.MILLISECONDS | 17
12821285
}
12831286

1287+
def 'can use relative git.root'() {
1288+
given:
1289+
def subdir = new File(projectDir, 'subdir')
1290+
subdir.mkdirs()
1291+
['build.gradle', 'settings.gradle'].each {
1292+
def file = new File(projectDir, it)
1293+
Files.move(file.toPath(), new File(subdir, it).toPath())
1294+
}
1295+
new File(subdir, 'gradle.properties') << 'git.root=..'
1296+
1297+
when:
1298+
def result = GradleRunner.create()
1299+
.withProjectDir(subdir)
1300+
.withArguments('help', '-s')
1301+
.withPluginClasspath()
1302+
.build()
1303+
1304+
then:
1305+
result.task(':help').outcome == TaskOutcome.SUCCESS
1306+
}
12841307

12851308

12861309
private void replaceDevWithImmutableSnapshot() {

src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ReleasePlugin implements Plugin<Project> {
5757
@CompileDynamic
5858
@Inject
5959
ReleasePlugin(Project project, ExecOperations execOperations, ProviderFactory providerFactory) {
60-
this.gitRoot = project.hasProperty('git.root') ? new File(project.property('git.root')) : project.rootProject.projectDir
60+
this.gitRoot = project.hasProperty('git.root') ? project.file(project.property('git.root')) : project.rootProject.projectDir
6161
this.gitBuildService = project.getGradle().getSharedServices().registerIfAbsent("gitBuildService", GitBuildService.class, spec -> {
6262
spec.getParameters().getGitRootDir().set(gitRoot)
6363
}).get()

src/main/groovy/nebula/plugin/release/git/base/BaseReleasePlugin.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class BaseReleasePlugin implements Plugin<Project> {
4141

4242
void apply(Project project) {
4343
ReleasePluginExtension releasePluginExtension = project.extensions.create('release', ReleasePluginExtension, project)
44-
File gitRoot = project.hasProperty('git.root') ? new File(project.property('git.root')) : project.rootProject.projectDir
44+
File gitRoot = project.hasProperty('git.root') ? project.file(project.property('git.root')) : project.rootProject.projectDir
4545
this.gitBuildService = project.getGradle().getSharedServices().registerIfAbsent("gitBuildService", GitBuildService.class, spec -> {
4646
spec.getParameters().getGitRootDir().set(gitRoot)
4747
})

src/main/groovy/nebula/plugin/release/git/base/ReleasePluginExtension.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ReleasePluginExtension {
6767
@CompileDynamic
6868
@Inject
6969
ReleasePluginExtension(Project project) {
70-
File gitRoot = project.hasProperty('git.root') ? new File(project.property('git.root')) : project.rootProject.projectDir
70+
File gitRoot = project.hasProperty('git.root') ? project.file(project.property('git.root')) : project.rootProject.projectDir
7171
this.project = project
7272
this.gitBuildService = project.getGradle().getSharedServices().registerIfAbsent("gitBuildService", GitBuildService.class, spec -> {
7373
spec.getParameters().getGitRootDir().set(gitRoot)

0 commit comments

Comments
 (0)