Tweaks to the jsword conditional build

Also add a FilterUtil class to JSword
master
Bradlee Speice 2014-05-05 00:53:32 -04:00
parent b7bab90dad
commit 4f03086a36
3 changed files with 56 additions and 10 deletions

View File

@ -6,17 +6,14 @@ task doBuildJSword (type: GradleBuild) {
buildFile = 'jsword-stub.gradle'
tasks = ['clean', 'ivy.check', 'ivy.download', 'ivy.task', 'ivy',
'init', 'mergeCode', 'compile', 'jar'] //, 'copyJarsToMinimalBible']
ext.outputJar = file('distribution/jsword.jar')
}
task conditionalBuildJSword () {
if(!file(doBuildJSword.ext.outputJar).exists())
doBuildJSword
ext.outputJar = file('distribution/jsword.jar')
outputs.upToDateWhen {
ext.outputJar.exists()
}
}
artifacts {
buildJSword(doBuildJSword.ext.outputJar) {
builtBy conditionalBuildJSword
builtBy doBuildJSword
}
}

View File

@ -64,11 +64,9 @@
<copy file="${jsword.resources}/BibleNames_zh_CN.properties"
tofile="${build.src}/BibleNames_zh.properties" overwrite="true" />
<!--
<copy todir="${build.src}" overwrite="true">
<fileset dir="${minbible.jsword.src}" />
</copy>
-->
</target>

View File

@ -0,0 +1,51 @@
package org.crosswire.jsword.book;
import org.crosswire.jsword.book.BookCategory;
import org.crosswire.jsword.book.BookFilter;
import org.crosswire.jsword.book.BookFilters;
import java.util.Arrays;
/**
* Module to help with some conversions between BookCategories and BookFilters
* Makes more sense to move it to JSword than incorporate in MinimalBible
*/
public class FilterUtil {
private static final BookCategory[] MAPPABLE_CATEGORIES = {BookCategory.BIBLE,
BookCategory.COMMENTARY, BookCategory.DAILY_DEVOTIONS, BookCategory.DICTIONARY,
BookCategory.GENERAL_BOOK, BookCategory.GLOSSARY, BookCategory.MAPS,
BookCategory.OTHER
};
private static final BookFilter[] MAPPABLE_FILTERS = {BookFilters.getBibles(),
BookFilters.getCommentaries(), BookFilters.getDailyDevotionals(), BookFilters.getDictionaries(),
BookFilters.getGeneralBooks(), BookFilters.getGlossaries(), BookFilters.getMaps(),
BookFilters.getNonBibles()
};
public static BookCategory categoryFromFilter(BookFilter f)
throws InvalidFilterCategoryMappingException {
int index = Arrays.asList(MAPPABLE_FILTERS).indexOf(f);
if (index != -1) {
return MAPPABLE_CATEGORIES[index];
} else {
throw new InvalidFilterCategoryMappingException("Can not map from filter: " + f.toString() + " to category.");
}
}
public static BookFilter filterFromCategory(BookCategory c)
throws InvalidFilterCategoryMappingException {
int index = Arrays.asList(MAPPABLE_CATEGORIES).indexOf(c);
if (index != -1) {
return MAPPABLE_FILTERS[index];
} else {
throw new InvalidFilterCategoryMappingException("Can not map from category: " + c.toString() + " to filter.");
}
}
public static class InvalidFilterCategoryMappingException extends Exception {
public InvalidFilterCategoryMappingException(String message) {
super(message);
}
}
}