Gradle JAVA Project Configuration Plugin

Specification run results

View on GitHub

Project configuration plugin

As a user I would like to be able to use a Gradle plugin to configure projects.

Total Runs Success Rate Failures Errors Skipped Total time (ms)
7 100.0% 0 0 0 1 minutes, 12.774 seconds

TestSubject:

Issues:

Features


should not throw an exception

Result: PASS Time: 2.740 seconds

def path = getClass().getResource('/simple-project')
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
project.plugins.apply('io.github.gregoranders.project-configuration')
noExceptionThrown()

should configure IDEA plugin

Result: PASS Time: 2.315 seconds

def path = getClass().getResource('/simple-project')
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
project.plugins.apply('java')
project.plugins.apply('idea')
project.properties.ext['description'] = 'description'
project.properties.ext['author'] = 'author'
project.properties.ext['email'] = 'email'
project.version = 'version'
project.java.sourceCompatibility = JavaVersion.VERSION_1_8
project.java.targetCompatibility = JavaVersion.VERSION_1_8
project.plugins.apply('io.github.gregoranders.project-configuration')
project.extensions.idea.module.downloadJavadoc
project.extensions.idea.module.downloadSources
project.rootProject.idea.project.vcs == 'Git'
project.rootProject.idea.project.jdkName == 'jdk-1.8'
project.rootProject.idea.project.languageLevel == new IdeaLanguageLevel('1.8')
noExceptionThrown()

should configure Checkstyle plugin

Result: PASS Time: 0.300 seconds

def path = getClass().getResource('/simple-project')
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
project.plugins.apply('java')
project.plugins.apply('checkstyle')
project.properties.ext['description'] = 'description'
project.properties.ext['author'] = 'author'
project.properties.ext['email'] = 'email'
project.properties.ext['checkstyleVersion'] = '1.0.0'
project.plugins.apply('io.github.gregoranders.project-configuration')
project.extensions.checkstyle.toolVersion == '1.0.0'
!project.extensions.checkstyle.ignoreFailures
noExceptionThrown()

should configure PMD plugin

Result: PASS Time: 0.165 seconds

def path = getClass().getResource('/simple-project')
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
project.plugins.apply('java')
project.plugins.apply('pmd')
project.properties.ext['description'] = 'description'
project.properties.ext['author'] = 'author'
project.properties.ext['email'] = 'email'
project.properties.ext['pmdVersion'] = '1.0.0'
project.plugins.apply('io.github.gregoranders.project-configuration')
project.extensions.pmd.toolVersion == '1.0.0'
project.extensions.pmd.consoleOutput
project.extensions.pmd.incrementalAnalysis
!project.extensions.pmd.ignoreFailures
project.extensions.pmd.ruleSetConfig != ''
project.tasks.cpdMain != null
noExceptionThrown()

should configure JaCoCo plugin

Result: PASS Time: 0.254 seconds

def path = getClass().getResource('/simple-project')
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
project.plugins.apply('java')
project.plugins.apply('jacoco')
project.properties.ext['description'] = 'description'
project.properties.ext['author'] = 'author'
project.properties.ext['email'] = 'email'
project.properties.ext['jacocoVersion'] = '1.0.0'
project.plugins.apply('io.github.gregoranders.project-configuration')
project.extensions.jacoco.toolVersion == '1.0.0'
noExceptionThrown()

should build project with plugin enabled

Result: PASS Time: 57.784 seconds

def path = getClass().getResource('/simple-project')
def result = GradleRunner.create()
    .withProjectDir(Paths.get(path.toURI()).toFile())
    .withPluginClasspath()
    .withEnvironment([
        'CI'            : 'true',
        'GPG_KEY_ID'    : '0xfsahgdf237643257',
        'GPG_KEY'       : 'test',
        'GPG_PASSPHRASE': 'test',
    ])
    .withArguments(getGradleJVMArgs(), 'clean', 'check', 'build')
    .build()
result.output.contains(':checkstyleMain')
result.output.contains(':checkstyleTest SKIPPED')
result.output.contains(':pmdMain')
result.output.contains(':pmdTest SKIPPED')
result.output.contains(':cpdMain')
result.output.contains('spotbugsMain')
result.output.contains('spotbugsTest SKIPPED')
result.output.contains(':jacocoTestReport')
result.output.contains(':jacocoTestCoverageVerification')
result.output.contains(':dependencyCheckAnalyze')
result.output.contains(':sourcesJar')
noExceptionThrown()

should fail build project with plugin enabled and code containing duplications

Result: PASS Time: 9.138 seconds

def path = getClass().getResource('/simple-project-with-duplications')
GradleRunner.create()
    .withProjectDir(Paths.get(path.toURI()).toFile())
    .withPluginClasspath()
    .withArguments(getGradleJVMArgs(), 'clean', 'check')
    .build()
UnexpectedBuildFailure exception = thrown()
exception.getMessage().contains('Copy/Paste analysis found 6')