Skip to content

Commit

Permalink
fix: remove SNAPSHOT doc for all versions of current branch
Browse files Browse the repository at this point in the history
  • Loading branch information
grv87 committed Jul 1, 2018
1 parent 8159228 commit 38575f3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/groovy/org/fidata/gradle/ProjectPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ import org.gradle.api.artifacts.ResolutionStrategy
import de.gliderpilot.gradle.semanticrelease.UpdateGithubRelease
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
import com.dorongold.gradle.tasktree.TaskTreeTask
import java.util.regex.Matcher
import java.util.regex.Pattern
import com.github.zafarkhaja.semver.Version

/**
* Provides an environment for a general, language-agnostic project
Expand Down Expand Up @@ -347,7 +350,20 @@ final class ProjectPlugin extends AbstractPlugin {
* CAVEAT:
* SNAPSHOT documentation for other branches should be removed manually
*/
preserve.exclude "$project.version/" // TODO - directory ? **
preserve.exclude { FileTreeElement fileTreeElement ->
Pattern snapshotSuffix = ~/-SNAPSHOT$/
Matcher m = snapshotSuffix.matcher(fileTreeElement.relativePath.segments[0])
if (!m.find()) {
return false
}
String dirVersion = m.replaceFirst('')
String projectVersion = project.version.toString().replaceFirst(snapshotSuffix, '')
try {
return Version.valueOf(dirVersion).preReleaseVersion == Version.valueOf(projectVersion).preReleaseVersion
} catch (ignored) {
return false
}
}
commitMessage.set COMMIT_MESSAGE_TEMPLATE.make(
type: 'docs',
subject: "publish documentation for version ${ project.version }",
Expand Down

0 comments on commit 38575f3

Please sign in to comment.