JAR file library enabled using Gradle fileTree not displaying Java code

I created a new Java project in IntelliJ IDEA using its Gradle project template, and I'm trying to set up a library so that my project can use it. I saved the library JAR file ./libs/frink-2014-02-17.jarin the project. I wrote in dependenciesmy section . But my Java code cannot see this library. When I try to build a project, the compiler complains that it refers to a package that does not exist.build.gradleruntime fileTree(dir: 'libs', include: '*.jar')import frink.parser.Frink;

How can I fix my build errors so that I can use the Frink library in my Java project?

More details

Frink library . Frink is not in the Maven repository , so I downloaded my JAR file , renamed it so that it had a version in the file name (after Gradle docs recommendation ) and put it in libsthe root of the project. Then I copied the following line of code from the Gradle User Guide: File Dependencies , to try to include all the JAR files in the directory libsI created:

runtime fileTree(dir: 'libs', include: '*.jar')

But when I do a “Project” or run ./gradlew build, I get the following errors:

/…/frink-soulver/src/main/java/Main.java:1: package frink.parser does not exist
import frink.parser.Frink;
                   ^     
/…/frink-soulver/src/main/java/Main.java:5: cannot find symbol
symbol  : class Frink    
location: class Main     
        Frink interp = new Frink();
        ^                
/…/frink-soulver/src/main/java/Main.java:5: cannot find symbol
symbol  : class Frink    
location: class Main     
        Frink interp = new Frink();
                           ^
/…/frink-soulver/src/main/java/Main.java:11: package frink.errors does not exist
        } catch (frink.errors.FrinkEvaluationException fee) {
                             ^
4 errors                 
:compileJava FAILED

My IDE emits the same errors when I open and browse Main.javabefore compiling it.

Main.java, import, Frink. Frink online JavaDocs , JAR frink.parser. , , , .

runtime compile build.gradle, .

" ..." IDEA "", Frink JAR. "Gradle: guava-12.0", "Gradle: hamcrest-core-1.3", "Gradle: jsr305-2.0.3" "Gradle: junit-4.11". +, IDEA, , , .

Ive "Gradle fileTree" , , Im fileTree , .

Im new Gradle, IDEA Java . , - , . , theres Frink, JAR , .

build.gradle:

apply plugin: 'java'

sourceCompatibility = 1.6
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'

    /* commenting this out for the question because the error still happens without this
    // http://code.google.com/p/guava-libraries/wiki/UseGuavaInYourBuild
    runtime group: 'com.google.guava', name: 'guava', version: '12.0'
    // http://stackoverflow.com/questions/10007994/why-do-i-need-jsr305-to-use-guava-in-scala/10013226#10013226
    // I'll include this dependency in case I decide I want to use these annotations
    compile group: 'com.google.code.findbugs', name: 'jsr305', version: '2.0.3'
    */

    runtime fileTree(dir: 'libs', include: '*.jar')
}

, tree:

.
├── build
│   ├── classes
│   │   └── main
│   └── dependency-cache
├── build.gradle
├── frink-soulver.iml
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── libs
│   └── frink-2014-02-17.jar
├── out
│   ├── production
│   │   └── frink-soulver
│   └── test
│       └── frink-soulver
└── src
    ├── main
    │   ├── java
    │   │   └── Main.java
    │   └── resources
    └── test
        ├── java
        └── resources

Main.java:

import frink.parser.Frink;

public class Main {
    public static void main(String[] args) {
        Frink interp = new Frink();
        interp.setRestrictiveSecurity(true);

        try {
            String results = interp.parseString("2+2");
            System.out.println(results);
        } catch (frink.errors.FrinkEvaluationException fee) {
            // Do whatever you want with the exception
        }
    }
}
+3
2

runtime, , compile...

+2

runtime fileTree(dir: 'libs', include: '*.jar') compile files('libs/MyLibrary.jar'). .

issue Android- , .

0

All Articles