diff options
Diffstat (limited to 'src/main/frege/buildclient/config/BuildConfig.fr')
-rw-r--r-- | src/main/frege/buildclient/config/BuildConfig.fr | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main/frege/buildclient/config/BuildConfig.fr b/src/main/frege/buildclient/config/BuildConfig.fr index 7c3290f..616b0bd 100644 --- a/src/main/frege/buildclient/config/BuildConfig.fr +++ b/src/main/frege/buildclient/config/BuildConfig.fr @@ -50,7 +50,6 @@ maybeOr :: a -> Maybe a -> a maybeOr _ (Just x) = x maybeOr x Nothing = x - data ArchiveFormat = Zip derive Show ArchiveFormat @@ -74,14 +73,22 @@ findSource (ASTDirective _ [ASTWord name] _) = fail ("Unknown source type " ++ n findSource _ = fail "Please provide a source type" -data BuildSystem = GradleBuild { task::String, project :: Maybe String } +data BuildSystem = GradleBuild { task::String, project :: Maybe String, extraProperties :: [(String, String)] } derive Show BuildSystem findBuildSystem :: ASTDirective -> Either String BuildSystem -findBuildSystem (ASTDirective _ [ASTWord "gradle"] block) = do - task <- getTypedArg "task" "gradle task" block expectString - return $ GradleBuild task $ (getArgDirective "project" block >>= expectString) +findBuildSystem (ASTDirective _ [ASTWord "gradle"] block) = + do + task <- getTypedArg "task" "gradle task" block expectString + let extraProperties = findDirectives "property" block >>= parseExtraProperty + return $ GradleBuild task (getArgDirective "project" block >>= expectString) extraProperties + where + parseExtraProperty directive = maybeToList $ do + name <- (getArg directive 0 >>= expectString) + value <- (getArg directive 1 >>= expectString) + return (name,value) + findBuildSystem _ = fail "Please provide a build system" parseBuildConfig :: [ASTDirective] -> Either String BuildConfig |