0

I have imported the project JCPABE ( https://github.com/TU-Berlin-SNET/JCPABE ) via Buildship Gradle Integration in eclipse Kepler on Windows 10.

Now, many packages show me similiar errors, concerning 5-10 classes that are not existing, seems like they all are belonging to the package cpabe.policyparser. This package exists, but seems to lack certain java classes.

It seems like they are declared in gradle.build correctly, e.g.

compileJavacc {
    inputDirectory = compileJjtree.outputDirectory
    outputDirectory = file('generated/javacc/cpabe/policyparser')
}

But I cant find them in my project or the project or the workspace folder. How can I include them?

Missing classes are for example

Node
ParseException
ASTStart
TokenMgrError
ParseTree
attr1bute
  • 21
  • 5
  • It seems those classes must be generated by JavaCC (see https://github.com/TU-Berlin-SNET/JCPABE/blob/master/build.gradle#L28). execute a gradle build, and add the directory containing the generated classes to the source path or classpath (depending on whether the task generates source files or class files). – JB Nizet Jul 02 '17 at 12:34
  • Hi, I have tried this out now, but still the same problem. The console also logs this errors: File "Node.java" does not exist. Will create one. File "SimpleNode.java" does not exist. Will create one. File "ASTStart.java" does not exist. Will create one. File "ASTExpression.java" does not exist. Will create one. which are exactly those which are shown as missing in my code – attr1bute Jul 02 '17 at 12:54
  • So, what did you do after those files were generated? Did you add the package-root folder where the files were generated as a source path of your eclipse project? – JB Nizet Jul 02 '17 at 12:56
  • Okay to be honest, I am not sure about both components here: I have downloaded the git projected and imported it via gradle buildship. It seems like all the .java docs are still linked to my download file. In my workspace there are no new libraries aswell.. And on the other hand i am also not sure where to change my package-root folder – attr1bute Jul 02 '17 at 13:06
  • Okay I am getting closer now. I right clicked the project and found something like "refresh gradle" or anything like this. all the missing .java exist now.. I still am not able to run the project - but this may be a functional problem now. I will have a closer look at it. Thank you a lot JB Nizet, for now – attr1bute Jul 02 '17 at 13:12
  • It's been a while I haven't used Eclipse. But I never advised to change any folder. I advised to **add** a source folder to the project: the folder containing the package tree containing the generated source files (which is probebly `generated/javacc` or `generated/javacc/cpabe/policyparser`. Right click on your project, select "Properties", and you should have a tab displaying the source folders of your project. That said, I've just tried building the project, and it fails due to unexisting dependencies, so you should contact the project maintainer. Also, the gradle delete task is wrong. – JB Nizet Jul 02 '17 at 13:13

1 Answers1

2

There are I believe 2 ways to refresh your IDE classpaths.

Not yet ideal is to try to refresh the project using the plugin which you are using for Gradle integration I believe its Buildship (not sure I use IntelliJ)

Another solution to get this working without any IDE plugins is to apply plugin: eclipse in your build.gradle and just run gradle eclipse task to regenerate the classpaths.

you may also wish to add the generated folder to your sourceSets{} in your script.

sourceSets.main {
        java {
            srcDirs = [
                    "$projectDir/src/main/java",
                    "$projectDir/<path_to_your_generated_dir>",
            ]
            include '**/*.java'
        }
}
LazerBanana
  • 6,865
  • 3
  • 28
  • 47