Skip to content

Unresolved reference for standard java library in Gradle project #105

@MagnusMG

Description

@MagnusMG

I have a Gradle project written in Kotlin (mostly), and fwcd reports error unresolved reference on everything from the standard library (see the screendump below). When building the project in the terminal, with gradlew, everything works fine.

I'm using fwcd v0.2.26 on macos 12.5.1 and VSCode 1.70.2.

The folder structure is like this (I don't know how to present this very well)):

- app/
-- src/
-- build.gradle
- (other folders)
- settings.gradle

build.gradle

import java.nio.file.Files;
import java.nio.file.Paths;

plugins {
	id 'org.jetbrains.kotlin.jvm' version '1.6.21'
	id 'org.openjfx.javafxplugin' version '0.0.13'
	id 'org.beryx.jlink' version '2.25.0'
    id 'org.jetbrains.dokka' version '1.6.10'
	id 'antlr'	
}

repositories {
    mavenCentral()
    mavenLocal()
}


// ================= JavaFX
javafx {
	version = '18'
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

// ================= Antlr
generateGrammarSource {
    maxHeapSize = "128m"
    arguments += ['-package', 'se.magnusgunnarsson.hallkoll.generatedparser', '-listener']
	outputDirectory = file("src/main/java/se/magnusgunnarsson/hallkoll/generatedparser") 
}

sourceSets {
    generated {
        java.srcDir 'src/main/java/se/magnusgunnarsson/hallkoll/generatedparser'
    }
}

clean{
	delete 'src/main/java/se/magnusgunnarsson/hallkoll/generatedparser'
}


// ================= Java
compileJava {
	dependsOn generateGrammarSource
    options.compilerArgs += ["-Aproject=${project.group}/${project.name}"]
	source sourceSets.generated.java, sourceSets.main.java
	destinationDirectory = compileKotlin.destinationDir 
}


java {
	toolchain {
		languageVersion.set(JavaLanguageVersion.of("11"))
	}
 	withSourcesJar()
}

sourcesJar {
	dependsOn generateGrammarSource
}

// ================= Kotlin
kotlin {
    jvmToolchain {
        languageVersion.set(JavaLanguageVersion.of("11")) // "8"
    }
}

compileKotlin {
	dependsOn generateGrammarSource
}

application {
	mainModule = 'hallkoll'
    mainClass = 'se.magnusgunnarsson.hallkoll.HallKoll'
	applicationName = 'HallKoll'
}

// ================ JLink
jlink {
    launcher {
        name = "hallkoll"
    }
    imageZip.set(project.file("${project.buildDir}/image-zip/hallkoll-image.zip"))	
}

// ================== Dokka

dokkaHtml.configure {
    dokkaSourceSets {
        named("main") {
            includeNonPublic.set(true)
        }
        configureEach {
            includes.from("src/main/kotlin/se/magnusgunnarsson/hallkoll/packages-documentation.md")
        }
    }
}



// ============== Test
test {
    useJUnitPlatform()
	onlyIf { project.hasProperty('runtests') }
}

// ================= Package dependencies
dependencies {
    implementation platform('org.jetbrains.kotlin:kotlin-bom')
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
   	antlr 'org.antlr:antlr4:4.10.1'
   	implementation 'org.antlr:antlr4-runtime:4.10.1'
    implementation 'se.explodera:util:1.0'
    implementation 'se.magnusgunnarsson:kutil:1.0'
	implementation 'org.apache.derby:derby:10.13.1.1'
}

settings.gradle:

rootProject.name = 'HallKoll'
include('app')

Problem

screendump

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions