Gradle: either path nor baseDir may be null or empty string

1.4k views Asked by At

I have tried to build me a plugin to run pdflatex (and at a later point in time bibtex) using gradle.

Unfortunately I am stuck with an error I don't understand: Neither path nor baseDir may be null or empty string. path='null' basedir='/home/me/paper'

Here is my build.gradle:

apply plugin: LaTeXPlugin

project.latex{
    documentBase = "research_paper"
    cookDir = "cooked"
    jobname = "job"
    pdflatexargs = ["-synctex=1", "-interaction=nonstopmode", "-shell-escape"]
    rawDir = "."
}


class LaTeXPlugin implements Plugin<Project>{
    @Override
    void apply(Project project){
        project.extensions.create("latex", LaTeXPluginExtension)

        def pdflatex = "pdflatex"
        def bibtex = "bibtex"

        project.task("pdfLaTeX", type:Exec){
            doFirst {
                println "CookDir $project.latex.cookDir"
                println "PdfLaTeX $project.latex.jobname"
                println "args: " + project.latex.pdflatexargs
                println "docBase: " + project.latex.documentBase
                println "rawDir:" + project.latex.rawDir
                println "path: $project.path"
                println "$project.rootDir"
            }

            outputs.dir(project.latex.cookDir)
            outputs.upToDateWhen{false}

            commandLine =[pdflatex] + project.latex.pdflatexargs + ["-jobname=$project.latex.jobname", "-output-directory=$project.latex.cookDir"] + [project.latex.documentBase + '.tex']
            doLast{
                println "PdfLaTeX done."
            }
        }
    }
}

class LaTeXPluginExtension {
    String documentBase
    String jobname
    String[] pdflatexargs
    String cookDir
    String rawDir
}

and here is the full output of running gradle pdflatex --stacktrace

gradle pdfLaTeX --stacktrace
:pdfLaTeX
FAILURE: Build failed with an exception.

* What went wrong:
Neither path nor baseDir may be null or empty string. path='null' basedir='/home/steffensky/CISPA/BachelorThesis/paper'

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
java.lang.IllegalArgumentException: Neither path nor baseDir may be null or empty string. path='null' basedir='/home/steffensky/CISPA/BachelorThesis/paper'
        at org.gradle.api.internal.file.BaseDirFileResolver.doResolve(BaseDirFileResolver.java:65)
        at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:81)
        at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:63)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileCollectionConverter.convertInto(DefaultFileCollectionResolveContext.java:177)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:138)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileCollections(DefaultFileCollectionResolveContext.java:85)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileCollectionConverter.convertInto(DefaultFileCollectionResolveContext.java:161)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:102)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileCollections(DefaultFileCollectionResolveContext.java:85)
        at org.gradle.api.internal.file.CompositeFileCollection.getSourceCollections(CompositeFileCollection.java:162)
        at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:45)
        at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:65)
        at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.outputFiles(CacheBackedTaskHistoryRepository.java:115)
        at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.getHistory(CacheBackedTaskHistoryRepository.java:49)
        at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository.getStateFor(DefaultTaskArtifactStateRepository.java:54)
        at org.gradle.api.internal.changedetection.changes.ShortCircuitTaskArtifactStateRepository.getStateFor(ShortCircuitTaskArtifactStateRepository.java:47)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:49)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
        at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
        at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:48)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)



BUILD FAILED

Total time: 1.285 secs

Hopefully one of you can point me in the right direction. Thanks in advance.

2

There are 2 answers

0
Forty2 On BEST ANSWER

found the error

for some reason gradle did not like:

outputs.dir(project.latex.cookDir)

after removing it I only had to fix some scoping errors

0
reallyinsane On

Instead of writing a new plugin and doing all configuration explicitly you could try the new gradle plugin for running latex: https://github.com/reallyinsane/mathan-latex-maven-plugin/blob/master/gradle.md