Skip to content

Commit 9dff681

Browse files
author
Nicolai Parlog
committed
Make XP project page the canonical truth for excerpt on landing page
Every JUnit Pioneer project (at the moment, just XP) has its own project page with its own header inclduing the group ID, project ID, and version. The landing page displays the excerpt of one such project. Before this change, the ecerpts was duplicated in two files and needed to be kept in sync manually. Now, the landing page's expert is pulled from the XP project page. Related to #9
1 parent dea4cef commit 9dff681

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

build.gradle

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ task removeDocNav() {
6161
}
6262
}
6363

64-
task removeVersion() {
64+
task removeXpFromHome {
6565
doLast {
66-
description 'Removes current version from site-source/_pages/home.md'
66+
description 'Removes XP excerpt from _site-source/_pages/home.md'
6767
File home = file('site-source/_pages/home.md')
6868
String homeText = home.getText()
69-
String homeTextWithVersion = homeText.replaceAll(/`org.junit-pioneer : junit-pioneer : [^`]*`/, "`org.junit-pioneer : junit-pioneer : @xp:version`")
70-
home.setText(homeTextWithVersion)
69+
String homeTextWithoutXpExcerpt = homeText.replaceAll(/(?m)^excerpt: .*/, "excerpt: @xp:excerpt")
70+
home.setText(homeTextWithoutXpExcerpt)
7171
}
7272
}
7373

7474
task clean {
75-
dependsOn removeProjectPage, removeDocs, removeDocNav, removeVersion
75+
dependsOn removeProjectPage, removeDocs, removeDocNav, removeXpFromHome
7676
}
7777

7878
// ------
@@ -82,7 +82,7 @@ task clean {
8282
task copyProjectPage(type: Copy) {
8383
from 'junit-pioneer/docs/'
8484
include 'project-page.*'
85-
rename 'project-page.(.*)', 'xp.$1'
85+
rename 'project-page.adoc', 'xp.adoc'
8686
into 'site-source/_pages'
8787
}
8888

@@ -104,20 +104,34 @@ task insertDocNav() {
104104
}
105105

106106
task insertVersion() {
107+
dependsOn copyProjectPage
107108
doLast {
108-
description 'Inserts current XP version into site-source/_pages/home.md'
109+
description 'Inserts current XP version into XP about page'
109110
Properties properties = new Properties()
110111
file('junit-pioneer/version.properties').withInputStream { properties.load(it) }
111112
String version = properties.previousVersion
113+
File aboutXp = file('site-source/_pages/xp.adoc')
114+
String aboutXpText = aboutXp.getText()
115+
String aboutXpTextWithVersion = aboutXpText.replaceAll(/@xp:version/, version)
116+
aboutXp.setText(aboutXpTextWithVersion)
117+
}
118+
}
119+
120+
task insertXpIntoHome() {
121+
dependsOn insertVersion
122+
doLast {
123+
description 'Inserts XP excerpt into _site-source/_pages/home.md'
124+
String xpContent = file('site-source/_pages/xp.adoc').getText()
125+
String excerpt = xpContent.find(/excerpt: .*/)
112126
File home = file('site-source/_pages/home.md')
113127
String homeText = home.getText()
114-
String homeTextWithVersion = homeText.replaceAll(/@xp:version/, "${version}")
115-
home.setText(homeTextWithVersion)
128+
String homeTextWithXpExcerpt = homeText.replaceAll(/(?m)^excerpt: @xp:excerpt/, excerpt)
129+
home.setText(homeTextWithXpExcerpt)
116130
}
117131
}
118132

119133
task create {
120-
dependsOn copyProjectPage, copyDocs, insertDocNav, insertVersion
134+
dependsOn copyProjectPage, copyDocs, insertDocNav, insertVersion, insertXpIntoHome
121135
}
122136

123137
// -----

0 commit comments

Comments
 (0)