Skip to content

Commit

Permalink
changed version plugin properties set from 'covention' to 'set'
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaquimmnetto committed Jul 7, 2021
1 parent ddf59ac commit dd86706
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,47 @@ class PluginsPluginIntegrationSpec extends IntegrationSpec {
"publishGroovydocs" | _
}

@Unroll
def "version publish API docs with correct settings"() {
given: "a future output directory"
fork = true
def docsExportDir = new File(projectDir, PluginsPlugin.DOC_EXPORT_DIR)
def classDoc = new File(docsExportDir, "net/wooga/plugins/test/HelloWorld.html")

assert !docsExportDir.exists()

and: "a temp java file"
writeHelloWorldGroovy("net.wooga.plugins.test")

and: "a gradle plugin bundle configured"
buildFile << """
pluginBundle {
website = 'https://plugins.com/wooga/atlas-test'
vcsUrl = 'https://github.com/wooga/atlas-test'
tags = ['plugins', 'test', 'internal']
plugins {
plugins {
id = 'net.wooga.test'
displayName = 'Integration Test'
description = 'This plugin provides no value'
}
}
}
""".stripIndent()

when:
runTasksSuccessfully(taskToRun)

then:
classDoc.text.contains "Integration Test API"
classDoc.text.contains "<!-- Generated by groovydoc -->"

where:
taskToRun | _
"publishGroovydocs" | _
}

void writePluginMetaFile(String pluginID, String pluginClassname, File baseDir = getProjectDir()) {
String path = "src/main/resources/META-INF/gradle-plugins/${pluginID}.properties"
def javaFile = createFile(path, baseDir)
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/wooga/gradle/plugins/PluginsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ class PluginsPlugin implements Plugin<Project> {
private static void configureVersionPluginExtension(Project project) {
def versionExt = project.extensions.findByType(VersionPluginExtension)
if(versionExt) {
versionExt.versionScheme.convention(VersionScheme.semver2)
versionExt.versionCodeScheme.convention(VersionCodeScheme.releaseCount)
versionExt.versionScheme.set(VersionScheme.semver2)
versionExt.versionCodeScheme.set(VersionCodeScheme.releaseCount)
}
}

Expand Down
58 changes: 46 additions & 12 deletions src/test/groovy/wooga/gradle/plugins/PluginsPluginSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ import wooga.gradle.github.publish.GithubPublishPlugin
import wooga.gradle.github.publish.tasks.GithubPublish
import wooga.gradle.githubReleaseNotes.GithubReleaseNotesPlugin
import wooga.gradle.githubReleaseNotes.tasks.GenerateReleaseNotes
import wooga.gradle.version.VersionCodeScheme
import wooga.gradle.version.VersionPlugin
import wooga.gradle.version.VersionPluginExtension
import wooga.gradle.version.VersionScheme

class PluginsPluginSpec extends ProjectSpec {
public static final String PLUGIN_NAME = 'net.wooga.plugins'
Expand Down Expand Up @@ -198,18 +201,6 @@ class PluginsPluginSpec extends ProjectSpec {
ideaModel.module.scopes["TEST"]["plus"].contains(integrationTestCompileConfiguration)
}

def createSrcFile(String folderStr, String filename) {
File folder = new File(projectDir, folderStr)
folder.mkdirs()
File srcFile = new File(folder, filename)
srcFile.createNewFile()
srcFile << """\
class ${filename.split("\\.")[0]} {
}
""".stripIndent()
return folder
}

def "configures sonarqube extension with default property values if none provided"(String ghCompany, String ghRepoName, String expectedProjectKey){
given: "configured github plugin"
if(!ghCompany.empty && !ghRepoName.empty) {
Expand Down Expand Up @@ -268,4 +259,47 @@ class PluginsPluginSpec extends ProjectSpec {
"sonar.tests" | "test/folder"
"sonar.jacoco.reportPaths" | "jacoco/report.exec"
}

def "configure version extension with default values"() {
given: "project with plugins plugin applied"
project.plugins.apply(PLUGIN_NAME)
project.evaluate()

expect: "version extension to exist"
VersionPluginExtension versionExt = project.extensions.getByType(VersionPluginExtension)
versionExt != null
and: "Version scheme to be semver2"
versionExt.versionScheme.get() == VersionScheme.semver2
and: "Version code scheme to be releaseCount"
versionExt.versionCodeScheme.get() == VersionCodeScheme.releaseCount
}

def "override version extension default values with custom ones"() {
given: "project with plugins plugin applied"
project.plugins.apply(PLUGIN_NAME)
project.evaluate()

and: "existing version extension in the plugin"
VersionPluginExtension versionExt = project.extensions.getByType(VersionPluginExtension)

when: "setting extension properties to distinct values"
versionExt.versionScheme("staticMarker")
versionExt.versionCodeScheme("releaseCountBasic")

then: "values should be the ones that has been set"
versionExt.versionScheme.get() == VersionScheme.staticMarker
versionExt.versionCodeScheme.get() == VersionCodeScheme.releaseCountBasic
}

def createSrcFile(String folderStr, String filename) {
File folder = new File(projectDir, folderStr)
folder.mkdirs()
File srcFile = new File(folder, filename)
srcFile.createNewFile()
srcFile << """\
class ${filename.split("\\.")[0]} {
}
""".stripIndent()
return folder
}
}

0 comments on commit dd86706

Please sign in to comment.