Skip to content

Commit

Permalink
validation refactoring, packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Priadka committed Nov 16, 2017
1 parent 1c38509 commit d9f5dc7
Show file tree
Hide file tree
Showing 33 changed files with 266 additions and 183 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import info.solidsoft.gradle.pitest.extension.ScmPitestPluginExtension
import info.solidsoft.gradle.pitest.task.AbstractPitestTask
import info.solidsoft.gradle.pitest.task.PitestTask
import info.solidsoft.gradle.pitest.task.ScmPitestTask
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
Expand Down Expand Up @@ -65,9 +66,6 @@ class PitestPlugin implements Plugin<Project> {
pitestTask = project.tasks.create(PluginConstants.PITEST_TASK_NAME, PitestTask)
scmPitestTask = project.tasks.create(PluginConstants.SCM_PITEST_TASK_NAME, ScmPitestTask)
configurePitestTaskFromExtension(pitestTask, pitestExtension)
scmPitestTask.addValidator(new GoalValidator(scmPitestTask))
scmPitestTask.addValidator(new ConnectionTypeValidator(scmPitestTask))
scmPitestTask.addValidator(new CustomStrategyValidator(scmPitestTask))
configureScmTaskFromExtension(scmPitestTask, scmPitestExtension)
}
project.afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package info.solidsoft.gradle.pitest.scm
package info.solidsoft.gradle.pitest.exception

class ChangeLogException extends Exception {
ChangeLogException(String var1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package info.solidsoft.gradle.pitest.scm
package info.solidsoft.gradle.pitest.exception

class InvalidChangeLogStrategyException extends Exception {
InvalidChangeLogStrategyException(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package info.solidsoft.gradle.pitest.exception

class PitestTaskValidationException extends Exception {

PitestTaskValidationException(String var1) {
super(var1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.gradle.api.Incubating
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.TaskInstantiationException

/**
* Extension class with configurable parameters for Pitest plugin.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package info.solidsoft.gradle.pitest.extension

import info.solidsoft.gradle.pitest.scm.ChangeLogStrategy
import info.solidsoft.gradle.pitest.scm.ScmConnection
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
package info.solidsoft.gradle.pitest.scm

import java.util.logging.Logger

class PathToClassNameConverter {
Set<String> sourceSets

Set<String> sourceSetsPaths

PathToClassNameConverter(Collection<String> sourceSets) {
this.sourceSets = new HashSet<>(sourceSets)
this.sourceSetsPaths = new HashSet<>(sourceSets)
}

List<String> convertPathNamesToClassName(List<String> pathNames) {
def result = []
pathNames.each {
pathName ->
def sourceRoot = sourceSets.find { pathName.contains(it)}
def sourceRoot = sourceSetsPaths.find { pathName.contains(it)}
if (sourceRoot && pathName.indexOf(".") != -1) {
result.add(transformToCanonicalName(sourceRoot, pathName))
}
}
Logger.getLogger(PathToClassNameConverter.getClass().getName()).info("@@@@@@@@RESULT: $result")
Logger.getLogger("$pathNames")
return result
}

private String transformToCanonicalName(String sourceSet, String path) {
private static String transformToCanonicalName(String sourceSet, String path) {
def pathWithoutSourceRootPrefix = path.substring(sourceSet.length() + 1, path.length())
def pathWithoutExtension = pathWithoutSourceRootPrefix.substring(0, pathWithoutSourceRootPrefix.lastIndexOf("."))
return pathWithoutExtension.replaceAll("/",".")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package info.solidsoft.gradle.pitest.scm

class ScmContext {

File scmRoot
String startVersion
String startVersionType
String endVersion
String endVersionType

private ScmContext(Builder builder) {
this.scmRoot = builder.scmRoot
this.startVersionType = builder.startVersionType
this.startVersion = builder.startVersion
this.endVersionType = builder.endVersionType
this.endVersion = builder.endVersion
}

static class Builder {
File scmRoot
String startVersion
String startVersionType
String endVersion
String endVersionType

Builder scmRoot(String scmRootPath) {
this.scmRoot = new File(scmRootPath)
return this
}

Builder scmRoot(File scmRoot) {
this.scmRoot = scmRoot
return this
}

Builder startVersion(String startVersion) {
this.startVersion = startVersion
return this
}

Builder startVersionType(String startVersionType) {
this.startVersionType = startVersionType
return this
}

Builder endVersion(String endVersion) {
this.endVersion = endVersion
return this
}

Builder endVersionType(String endVersionType) {
this.endVersionType = endVersionType
return this
}

ScmContext build() {
return new ScmContext(this)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package info.solidsoft.gradle.pitest.scm
package info.solidsoft.gradle.pitest.scm.strategy

import info.solidsoft.gradle.pitest.exception.ChangeLogException
import org.apache.maven.scm.ScmFileSet
import org.apache.maven.scm.manager.NoSuchScmProviderException
import org.apache.maven.scm.manager.ScmManager
import org.apache.maven.scm.repository.ScmRepository
import org.apache.maven.scm.repository.ScmRepositoryException

abstract class AbstractChangeLogStrategy implements ChangeLogStrategy {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package info.solidsoft.gradle.pitest.scm
package info.solidsoft.gradle.pitest.scm.strategy

import org.apache.maven.scm.manager.ScmManager

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package info.solidsoft.gradle.pitest.scm
package info.solidsoft.gradle.pitest.scm.strategy

import org.apache.maven.scm.ScmBranch
import org.apache.maven.scm.ScmFileSet
import org.apache.maven.scm.ScmRevision
import org.apache.maven.scm.ScmTag
import org.apache.maven.scm.ScmVersion
import info.solidsoft.gradle.pitest.exception.ChangeLogException
import org.apache.maven.scm.*
import org.apache.maven.scm.command.changelog.ChangeLogScmRequest
import org.apache.maven.scm.command.changelog.ChangeLogScmResult
import org.apache.maven.scm.manager.ScmManager
Expand All @@ -24,6 +21,11 @@ class CustomChangeLogStrategy extends AbstractChangeLogStrategy {
String endVersionType
String endVersion

Builder fileSet(File fileSet) {
this.scmFileSet = new ScmFileSet(fileSet)
return this
}

Builder fileSet(String path) {
this.scmFileSet = new ScmFileSet(new File(path))
return this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package info.solidsoft.gradle.pitest.scm
package info.solidsoft.gradle.pitest.scm.strategy

import info.solidsoft.gradle.pitest.exception.ChangeLogException
import org.apache.maven.scm.ChangeSet
import org.apache.maven.scm.ScmFileSet
import org.apache.maven.scm.command.changelog.ChangeLogScmRequest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package info.solidsoft.gradle.pitest.scm
package info.solidsoft.gradle.pitest.scm.strategy

import info.solidsoft.gradle.pitest.exception.ChangeLogException
import org.apache.maven.scm.ScmFileSet
import org.apache.maven.scm.command.status.StatusScmResult
import org.apache.maven.scm.manager.ScmManager
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package info.solidsoft.gradle.pitest.scm.strategy.factory

import info.solidsoft.gradle.pitest.scm.strategy.ChangeLogStrategy

interface AbstractChangeLogStrategyFactory {
ChangeLogStrategy fromType(String type)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package info.solidsoft.gradle.pitest.scm.strategy.factory

import info.solidsoft.gradle.pitest.exception.InvalidChangeLogStrategyException
import info.solidsoft.gradle.pitest.scm.ScmContext
import info.solidsoft.gradle.pitest.scm.strategy.ChangeLogStrategy
import info.solidsoft.gradle.pitest.scm.strategy.CustomChangeLogStrategy
import info.solidsoft.gradle.pitest.scm.strategy.LastCommitStrategy
import info.solidsoft.gradle.pitest.scm.strategy.LocalChangesStrategy

class ChangeLogStrategyFactory implements AbstractChangeLogStrategyFactory{

private ScmContext scmContext

ChangeLogStrategyFactory (ScmContext scmContext) {
this.scmContext = scmContext
}

@Override
ChangeLogStrategy fromType(String goal) {
switch (goal) {
case 'lastCommit':
return new LastCommitStrategy(scmContext.getScmRoot())
case 'localChanges':
return new LocalChangesStrategy(scmContext.getScmRoot())
case 'custom':
return new CustomChangeLogStrategy.Builder()
.fileSet(scmContext.getScmRoot())
.startVersion(scmContext.getStartVersion())
.startVersionType(scmContext.getStartVersionType())
.endVersion(scmContext.getEndVersion())
.endVersionType(scmContext.getEndVersionType())
.build()
default:
throw new InvalidChangeLogStrategyException("Invalid goal, received: $goal, possible goals are [lastCommit, localChanges, custom]")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
package info.solidsoft.gradle.pitest.task

import groovy.transform.CompileStatic
import groovy.transform.PackageScope
import info.solidsoft.gradle.pitest.PitestPlugin

import java.util.logging.Logger

/**
* Gradle task implementation for Pitest.
*/
Expand Down
Loading

0 comments on commit d9f5dc7

Please sign in to comment.