Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working Directory for Gradle Configure is the extension, not the project folder #1616

Open
mattjhussey opened this issue Oct 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mattjhussey
Copy link

Extension Name: vscode-gradle
Extension Version: 3.16.4 (but tested back to 3.7.0)
OS Version: Windows 11
VSCode version: 1.93.1

Describe the bug
The working directory when configuring a gradle build is incorrect and set to: "c:\Users<user>.vscode\extensions\vscjava.vscode-gradle-3.16.4\lib. This means that having script that accesses files for capturing versions or running git in the repo fail.

To Reproduce
Add a file like this to the root:

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.jetbrains.kotlin.android)
}

android {
    namespace = "things"
    compileSdk = 34

    defaultConfig {
        applicationId = "things"
        minSdk = 21
        targetSdk = 34

        println("Current working directory: ${System.getProperty("user.dir")}")

        versionName = "1.0"
        versionCode = 1
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildFeatures {
        viewBinding = true
    }
}

dependencies {

    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.material)
    implementation(libs.androidx.constraintlayout)
    implementation(libs.androidx.navigation.fragment.ktx)
    implementation(libs.androidx.navigation.ui.ktx)
    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.androidx.espresso.core)
}

Expected behavior
The working directory should be the working directory of the project. I have tested and this is the behaviour of intellij and the CLI when running the same gradle project.

Screenshots
If applicable, add screenshots to help explain your problem.

Output from "Gradle for Java"
You can find this by clicking on the "Output" panel, then selecting the "Gradle for Java" channel from the dropdown.

[error] Error getting build for c:\Users\<user>\Documents\workspace\thing: The supplied build action failed with an exception.
[info] Found 0 tasks
[error] [gradle-server] The supplied build action failed with an exception.
[info] Build file changed: c:\Users\<user>\Documents\workspace\thing\app\build.gradle.kts
[debug] Refreshing tasks
[info] Java Home: C:\Program Files\Java\jdk-17.0.5
[info] JVM Args: --add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx2048m,-Dfile.encoding=UTF-8,-Duser.country=GB,-Duser.language=en,-Duser.variant
[info] Gradle User Home: C:\Users\<user>\.gradle
[info] Gradle Version: 8.9
[info] > Configure project :app
Current working directory: c:\Users\<user>\.vscode\extensions\vscjava.vscode-gradle-3.16.4\lib

Does the bug still exist if you disable all other extensions?
Yes

Additional context
Does not match the standard behaviour of a gradle build.

@mattjhussey mattjhussey added the bug Something isn't working label Oct 14, 2024
@jdneo
Copy link
Member

jdneo commented Oct 15, 2024

Looks like the same issue as #1572

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants