Skip to content

Commit

Permalink
Merge pull request #21 from FrantisekGazo/develop
Browse files Browse the repository at this point in the history
Make configuration file required
  • Loading branch information
FrantisekGazo authored Dec 26, 2016
2 parents 8b23eef + 21bd154 commit 1abce78
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Blade.wiki
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

Version 2.5.1 *(2016-12-26)*
----------------------------

* Change: Configuration file is now required

Version 2.5.0 *(2016-12-26)*
----------------------------

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1536M

LIB_GROUP_ID = eu.f3rog.blade
ARTIFACT_ID = none
LIB_VERSION = 2.5.0
LIB_VERSION = 2.5.1

LIB_VERSION_DESC = Android Library for Boilerplate Destruction

Expand Down
11 changes: 7 additions & 4 deletions plugin/src/main/groovy/eu/f3rog/blade/plugin/BladePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class BladePlugin
// non-debug by default
public boolean debug = false
// include all modules by default
public String[] modules = LIB_MODULES
public String[] modules = []

@Override
public String toString() {
Expand All @@ -28,10 +28,11 @@ public final class BladePlugin
public static String ERROR_GRADLE_TOOLS_1_5_0_REQUIRED = "Blade plugin only supports android gradle plugin 1.5.0 or later!"
public static String ERROR_ANDROID_PLUGIN_REQUIRED = "'com.android.application' or 'com.android.library' plugin required!"
public static String ERROR_MODULE_DOES_NOT_EXIST = "Blade does not have module '%s'!"
public static String ERROR_APT_MISSING = "Apply apt plugin or update gradle plugin to >=2.2.0!"
public static String ERROR_APT_IS_MISSING = "Apply apt plugin or update gradle plugin to >=2.2.0!"
public static String ERROR_CONFIG_FILE_IS_MISSING = "Blade configuration file is missing! (more info here: https://github.com/FrantisekGazo/Blade/wiki#1-create-configuration-file)"

public static String LIB_GROUP_ID = "eu.f3rog.blade"
public static String LIB_VERSION = "2.5.0"
public static String LIB_VERSION = "2.5.1"
public static String LIB_CONFIG_FILE_NAME = "blade"
public static String[] LIB_MODULES = ["arg", "extra", "mvp", "parcel", "state"]

Expand Down Expand Up @@ -83,7 +84,7 @@ public final class BladePlugin
} else if (hasAnnotationProcessorConfiguration) {
return ['annotationProcessor', 'androidTestAnnotationProcessor']
} else {
throw new IllegalStateException(ERROR_APT_MISSING)
throw new IllegalStateException(ERROR_APT_IS_MISSING)
}
}

Expand Down Expand Up @@ -122,6 +123,8 @@ public final class BladePlugin
} else if (yamlConfigFile.exists()) {
Yaml yaml = new Yaml()
mConfig = yaml.loadAs(new FileInputStream(yamlConfigFile), BladeConfig.class)
} else {
throw new IllegalStateException(ERROR_CONFIG_FILE_IS_MISSING)
}

// check module names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,40 @@ final class BladePluginSpecification

then:
e != null
e.getMessage().contains(BladePlugin.ERROR_APT_MISSING)
e.getMessage().contains(BladePlugin.ERROR_APT_IS_MISSING)

where:
[gradleToolsVersion, gradleVersion, _, _, bladeFileType] << WHERE_DATA[0..1] + WHERE_DATA[3..4]
}

@Unroll
def "fail without blade file - for #gradleToolsVersion"() {
given:
projectFolder.addGradleFile(new GradleConfig()
.classpaths([buildGradleClasspath(gradleToolsVersion)] + aptClasspath + [bladeClasspath])
.plugins(["com.android.application"] + apt + ["blade"])
)

when:
Exception e = null
try {
GradleRunner.create()
.withGradleVersion(gradleVersion)
.withProjectDir(projectFolder.root)
.withArguments(':build')
.build()
} catch (Exception ex) {
e = ex
}

then:
e != null
e.getMessage().contains(BladePlugin.ERROR_CONFIG_FILE_IS_MISSING)

where:
[gradleToolsVersion, gradleVersion, aptClasspath, apt, _] << WHERE_DATA[0..2]
}

@Unroll
def "add correct dependencies - for #gradleToolsVersion, #bladeFileType"() {
given:
Expand Down Expand Up @@ -163,31 +191,6 @@ final class BladePluginSpecification
[gradleToolsVersion, gradleVersion, aptClasspath, apt, bladeFileType] << WHERE_DATA
}

@Unroll
def "build successfully without blade file - for #gradleToolsVersion"() {
given:
projectFolder.addGradleFile(new GradleConfig()
.classpaths([buildGradleClasspath(gradleToolsVersion)] + aptClasspath + [bladeClasspath])
.plugins(["com.android.application"] + apt + ["blade"])
.dependencies(["compile 'com.google.dagger:dagger:2.0.2'"]) // required for 'mvp' module
)

when:
BuildResult result = GradleRunner.create()
.withGradleVersion(gradleVersion)
.withProjectDir(projectFolder.root)
.withArguments(':build')
.build()

then:
result.task(":build").outcome == SUCCESS
result.task(":transformClassesWithBladeForDebug").outcome == SUCCESS
result.task(":transformClassesWithBladeForRelease").outcome == SUCCESS

where:
[gradleToolsVersion, gradleVersion, aptClasspath, apt, _] << WHERE_DATA[0..2]
}

@Unroll
def "build successfully [EXTRA, arg] modules - for #gradleToolsVersion, #bladeFileType"() {
given:
Expand Down

0 comments on commit 1abce78

Please sign in to comment.