javacc / javaccPlugin

A JavaCC plugin for Gradle
MIT License
33 stars 16 forks source link

Input directory does not work for multi-module projects #3

Closed davidbokor closed 9 years ago

davidbokor commented 10 years ago

Since the task uses getProject().getRootDir() to set the input directory, it tries to find the "src/main/javacc" directory under the root of my multi-module project instead of in the module directory itself.

As a workaround, I had to set the input directory manually but it would be nice if I didn't have to.

abillah commented 10 years ago

Hi David, I'm also having the same problem but being new to gradle, don't know how to set that. I wonder how you set the input directory manually.

Thanks,

-abdur

johnmartel commented 10 years ago

Hi guys,

I am currently on vacation, I will fix both issues when I come back early september. Sorry for the inconveniences. If you have patches, I will be happy to review and merge them at the same time.

Sent from my iPhone

On 2014-08-13, at 21:19, abillah notifications@github.com wrote:

Hi David, I'm also having the same problem but being new to gradle, don't know how to set that. I wonder how you set the input directory manually.

Thanks,

-abdur

— Reply to this email directly or view it on GitHub.

abillah commented 10 years ago

Very delighted to hear from you. Thank you very much. Enjoy your vacation.

-abdur

On 8/13/2014 2:53 PM, John Martel wrote:

Hi guys,

I am currently on vacation, I will fix both issues when I come back early september. Sorry for the inconveniences. If you have patches, I will be happy to review and merge them at the same time.

Sent from my iPhone

On 2014-08-13, at 21:19, abillah notifications@github.com wrote:

Hi David, I'm also having the same problem but being new to gradle, don't know how to set that. I wonder how you set the input directory manually.

Thanks,

-abdur

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/johnmartel/javaccPlugin/issues/3#issuecomment-52101349.

davidbokor commented 10 years ago

My workaround isn't elegant. I created a my own plugin as follows:

import ca.coglinc.gradle.plugins.javacc.CompileJavaccTask
import org.gradle.api.Plugin
import org.gradle.api.Project

class JavaCCPlugin implements Plugin<Project> {

    void apply(Project project) {
        project.plugins.apply('ca.coglinc.javacc')
        project.tasks.withType(CompileJavaccTask.class) {
            it.setInputDirectory(project.file("src/main/javacc"))
        }
    }
}
maoueh commented 9 years ago

You can use task configuration to configure input directory:

compileJavacc {
    inputDirectory = file('src/custom/directory')
}