-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfreshmark.gradle
63 lines (56 loc) · 1.76 KB
/
freshmark.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 干.mustRunAfter('base/changelog')
apply plugin: 'com.diffplug.gradle.spotless'
import com.diffplug.gradle.spotless.FreshMarkExtension
Action<FreshMarkExtension> freshmarkSetup = {
it.target '*.md'
it.indentWithSpaces(2)
it.trimTrailingWhitespace()
it.endWithNewline()
}
def changelogExt = null;
if (tasks.names.contains('changelogCheck')) {
changelogExt = spotlessChangelog
} else if (parent != null && parent.tasks.names.contains('changelogCheck')) {
changelogExt = parent.spotlessChangelog
}
spotless {
groovyGradle {
target '*.gradle'
clearSteps()
greclipse()
}
freshmark {
freshmarkSetup.execute(it)
properties {
if (changelogExt != null) {
it.put('versionLast', changelogExt.versionLast == null ? 'first-ever' : changelogExt.versionLast)
}
}
}
}
// if spotlessChangelog was applied to this project, use that to
// reformat the markdown files after the changelog has been bumped
if (changelogExt != null) {
// create a freshmark apply task manually
FreshMarkExtension freshmark = new FreshMarkExtension(spotless);
freshmarkSetup.execute(freshmark)
freshmark.properties {
// that uses versionNext as versionLast
it.put('versionLast', changelogExt.versionNext)
}
def changelogBumpFreshmark = freshmark.createIndependentTask('changelogBumpFreshmark')
changelogBumpFreshmark.setApply()
// freshmark should run after the changelog bump
changelogBumpFreshmark.dependsOn tasks.named('changelogBump')
def changelogBumpFreshmarkGitAdd = tasks.register('changelogBumpFreshmarkGitAdd') {
// this git add add should run after the freshmark
dependsOn(changelogBumpFreshmark)
// do the git add
doLast {
exec { commandLine 'git', 'add' , '*.md' }
}
}
tasks.named('changelogPush').configure {
dependsOn changelogBumpFreshmarkGitAdd
}
}