javacc / javaccPlugin

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

javaccPlugin should compile only the javacc file in the inputDirectory #28

Closed zosrothko closed 7 years ago

zosrothko commented 7 years ago

Hi

I have 3 jj files in the top directory and all are compiled by JavaCC while only the one in the input directory should be compiled

Z:\git\c\parser>c:\programfiles\gradle\bin\gradle compileJa
:compileJavacc
Java Compiler Compiler Version 6.1_2 (Parser Generator)
(type "javacc" with no arguments for help)
Reading from file Z:\git\c\parser\C.jj . . .
File "TokenMgrError.java" does not exist.  Will create one.
File "ParseException.java" does not exist.  Will create one.
File "Token.java" does not exist.  Will create one.
File "SimpleCharStream.java" does not exist.  Will create one.
Parser generated successfully.
Java Compiler Compiler Version 6.1_2 (Parser Generator)
(type "javacc" with no arguments for help)
Reading from file Z:\git\c\parser\src\main\javacc\C.jj . . .
Warning: Output directory "Z:\git\c\parser\build\generated\javacc\tmp\src\main\javacc" does not exist. Creating the directory.
File "TokenMgrError.java" does not exist.  Will create one.
File "ParseException.java" does not exist.  Will create one.
File "Token.java" does not exist.  Will create one.
File "SimpleCharStream.java" does not exist.  Will create one.
Parser generated with 0 errors and 1 warnings.
Java Compiler Compiler Version 6.1_2 (Parser Generator)
(type "javacc" with no arguments for help)
Reading from file Z:\git\c\parser\src\main\jtb\jtb.out.jj . . .
Warning: Output directory "Z:\git\c\parser\build\generated\javacc\tmp\src\main\jtb" does not exist. Creating the directory.
File "TokenMgrError.java" does not exist.  Will create one.
File "ParseException.java" does not exist.  Will create one.
File "Token.java" does not exist.  Will create one.
File "SimpleCharStream.java" does not exist.  Will create one.
Parser generated with 0 errors and 1 warnings.

BUILD SUCCESSFUL

build.gradle

Z:\git\c\parser>type build.gradle
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath group: 'ca.coglinc', name: 'javacc-gradle-plugin', version: '2.3.1'
    }
}
apply plugin: 'ca.coglinc.javacc'
compileJavacc {
    inputDirectory = projectDir
    outputDirectory = file(project.buildDir.absolutePath + '/generated/javacc')
//      arguments = [grammar_encoding: 'UTF-8', static: 'false']
}
johnmartel commented 7 years ago

You have set the inputDirectory to your $projectDir, which means you'll compile any javacc file that's under it! If you want to compile only what's under src/main/javacc, simply remove the inputDirectory configuration. This is the default value.

johnmartel commented 7 years ago

And I'm pretty sure you don't need the outputDirectory configuration either. You're basically outputting to the default location.

zosrothko commented 7 years ago

ok got it...thanks for your quick answer.