Reputation: 23
These are images about two my project: java project include: many package xyz. grails project, I reference to java project by two way:
So I have file TestsimiliraDetection.java
in grails project. It calls all packages in java project.
When I run TestsimiliraDetection.java
as java-aplication, it does not matter. But when I run ThirdGrails project as grails app, it produces the following error:
Compiling 3 source files [groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[groovyc] Compile error during compilation with javac.
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:7: error: package local.extractText.extractText does not exist
[groovyc] import local.extractText.extractText.ExtractPdf;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:8: error: package local.extractText.extractText does not exist
[groovyc] import local.extractText.extractText.GetSection;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:9: error: package local.extractText.extractText does not exist
[groovyc] import local.extractText.extractText.GetStructureOfFile;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:10: error: package local.extractText.getPositionPdf does not exist
[groovyc] import local.extractText.getPositionPdf.Page;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:11: error: package local.extractText.getPositionPdf does not exist
[groovyc] import local.extractText.getPositionPdf.Paragraph;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:12: error: package local.extractText.getPositionPdf does not exist
[groovyc] import local.extractText.getPositionPdf.Part;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:13: error: package local.extractText.getPositionPdf does not exist
[groovyc] import local.extractText.getPositionPdf.Section;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:14: error: package local.infoFile does not exist
[groovyc] import local.infoFile.infoThesis;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:15: error: package local.libs does not exist
[groovyc] import local.libs.Lib;
[groovyc] ^
[groovyc] A:\juno-workspace\ThirdGrails\src\java\readInput\TestSimitaryDetection.java:16: error: package local.lucene does not exist
[groovyc] import local.lucene.FindCopy;
.......
Here package xyz not found .xyz is package in my java-project. But it doesn't work. Is there a way to reference those projects? Why don't those packages compile? I also added class folder in java build path of grails project, but it still produces an error. Can anyone help me?
Upvotes: 0
Views: 1028
Reputation: 42174
If you want to add your Java code directly to Grails project you need to follow the standard classpath rule. In Grails you have this src/java
folder which is the root classpath for any Java code you would like to put into your project. Then if you import class like local.lucene.FindCopy
, the file src/java/local/lucene/FindCopy.java
has to exist.
Remember that Grails command like run-app
doesn't care about what you set in your Eclipse project build path. It only indicates the behavior of your IDE, but not Grails itself. But if you use e.g. GGTS (Groovy Grails Tool Suite), build path in src/java
should be defined by default for any Java project.
Consider also providing your Java dependencies as a maven artifacts. Basically if you put your Java code into the Maven project, you can simply add the dependency that will come from your local maven repository. It is widely described in the documentation - http://grails.github.io/grails-doc/2.3.x/guide/conf.html#dependencyResolution It's worth trying.
Upvotes: 1