vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Feature Request: configurable `defaultOutputDir` instead of hardcoded `bin`

Open pan3793 opened this issue 5 years ago • 20 comments
trafficstars

Feature Request

Please provide a configuration to change defaultOutputDir bin

Detail

I'm not an eclipse user, as I know, bin is widely used as a dir that stores shell scripts, but vscode java plugin uses it as the default output dir, and can not be changed by configuration, the only way I know is using gradle eclipse plugin to generate .classpath with modified config by groovy script in build.gradle, see #634

buildDir = "build/gradle"
apply plugin: 'java'
apply plugin: 'eclipse'
eclipse {
  classpath {
    defaultOutputDir = file('build/eclipse')
    file.whenMerged {
      entries.each { entry ->
        if (entry.kind == 'src' && entry.hasProperty('output')) {
          entry.output = entry.output.replace('bin/', "build/eclipse/")
        }
      }
    }
  }
}

@jdneo https://github.com/redhat-developer/vscode-java/issues/2801#issuecomment-1318256946

You can vote for https://github.com/redhat-developer/vscode-java/issues/1615 to help us prioritize.

If anyone encounter this issue, please comment / give 👍 / link related issue to this one, to help the team escalate the priority of this issue.

pan3793 avatar Sep 15 '20 07:09 pan3793

This would also be useful for projects that do not use any build manager. Currently no .classpath files are generated by vscode-java (which is good but removes any configuration tweaking) and built files seems to be saved in the workspace metadata folder (which I would like to change).

I would like to use vscode as my "build system" for one project as it is very easy to import .jar files in the classPath using the java.project.referencedLibraries property. But I also need to easily access the .class files.

Having a java.project.defaultOutputDir property that I could also set in my .vscode/config.json would enable me to save all the .class files in a directory of my choice.

n-peugnet avatar Oct 13 '20 16:10 n-peugnet

CC @jdneo, since he is working on tuning the classpath configuration UX.

testforstephen avatar Dec 18 '20 03:12 testforstephen

@jdneo Could you please have a look on this issue?

pan3793 avatar Mar 09 '21 07:03 pan3793

@n-peugnet The newest Language support for Java extension adds a new setting to set the output path for project without any build tools.

java.project.outputPath: A relative path to the workspace where stores the compiled output. Only effective in the WORKSPACE scope. The setting will NOT affect Maven or Gradle project.

@pan3793 Sorry currently there is no plan to make that setting be able to impact Maven/Gradle project. But we will keep an eye on this request.

jdneo avatar Mar 09 '21 07:03 jdneo

it's been one year

BrightTreeMan avatar Jul 12 '22 09:07 BrightTreeMan

can someone help me out?

BrightTreeMan avatar Jul 12 '22 09:07 BrightTreeMan

Really need this feature since our repo got bin/ for scripts.

kid1412621 avatar Jul 18 '22 10:07 kid1412621

here's the kotlin script version of the workaroud:

import org.gradle.plugins.ide.eclipse.model.Classpath
import org.gradle.plugins.ide.eclipse.model.SourceFolder
plugins {
    java
    eclipse
}
buildDir = file("build/gradle")
eclipse {
    classpath {
        defaultOutputDir = file("build/eclipse")
        file {
            whenMerged(
                    Action<Classpath> { ->
                        entries.filter { it.kind == "src" }.forEach {
                            if (it is SourceFolder) {
                                it.output = it.output.replace("bin/", "build/eclipse/")
                            }
                        }
                    }
            )
        }
    }
}

sify21 avatar Nov 03 '22 09:11 sify21

This buildship output folder issue is really annoying. It would be great to have a setting to be able to impact Maven/Gradle projects.

a-st avatar Nov 17 '22 08:11 a-st

@jdneo https://github.com/redhat-developer/vscode-java/issues/2801#issuecomment-1318256946

You can vote for https://github.com/redhat-developer/vscode-java/issues/1615 to help us prioritize.

If anyone encounter this issue, please comment / give 👍 / link related issue to this one, to help the team escalate the priority of this issue.

pan3793 avatar Nov 17 '22 09:11 pan3793

I onboard people at work. This issue confuses people and ultimately causes people to uninstall the extension.

gardner avatar Nov 21 '22 19:11 gardner

If you guys feel strongly about this issue, please vote for https://github.com/gradle/gradle/issues/23032. We can't do anything until this is fixed upstream.

fbricon avatar Dec 07 '22 19:12 fbricon

It would be good to prompt the user before downloading huge amounts of data and kicking off a resource intensive compile.

How do we prevent this extension from automatically building a project?

gardner avatar Dec 28 '22 21:12 gardner

If you guys feel strongly about this issue, please vote for gradle/gradle#23032. We can't do anything until this is fixed upstream.

It seems that there are related commit on gradle recently, see https://github.com/gradle/gradle/issues/23032, hope it can be applied to the plugin.

Kicey avatar Feb 12 '23 09:02 Kicey

23032 is "Complete" with no indication of a resolution. Are we still blocked by upstream? Does no one care that stupid files are being created incorrectly? Humans are too adaptable - too quick to "resolve" an issue with a workaround, instead of fixing the real problem. One dev fixes this and hundreds of teams get to stop being annoyed. WTF! This whole thing has been going on for almost 3 years. Abhorrent community support - all around.

dailytabs avatar Apr 16 '23 23:04 dailytabs

for anyone who is still encountering this issue, a workaround:

  • use Gradle wrapper 8.1+
  • in build.gradle, apply plugin eclipse, and add the following snippet
eclipse {
  classpath {
    baseSourceOutputDir = file('build')
  }
}

then the class files are generated in build folder.

CsCherrYY avatar Apr 18 '23 10:04 CsCherrYY

for anyone who is still encountering this issue, a workaround:

  • use Gradle wrapper 8.1+
  • in build.gradle, apply plugin eclipse, and add the following snippet
eclipse {
  classpath {
    baseSourceOutputDir = file('build')
  }
}

then the class files are generated in build folder.

That doesn't work for me.

Michel73 avatar May 16 '23 16:05 Michel73

That doesn't work for me.

After applying the patch, reset your LS by using "Java: Clean Java Language Server Workspace"

Kamii0909 avatar Sep 23 '23 10:09 Kamii0909

for anyone who is still encountering this issue, a workaround:

  • use Gradle wrapper 8.1+
  • in build.gradle, apply plugin eclipse, and add the following snippet
eclipse {
  classpath {
    baseSourceOutputDir = file('build')
  }
}

then the class files are generated in build folder.

That doesn't work for me.

This works, but adding it to build.gradle only for VS users and having 3 versions of everything in the build dir is quite suboptimal, gradle seems to be a second class citizen atm

kdaham avatar Sep 27 '23 07:09 kdaham

I use nvim-jdtls and I can use spring-boot-devtools with this configuration:

eclipse {
    classpath {
        baseSourceOutputDir = file('build/classes/java')
    }
}

ramonbakker avatar Jan 15 '24 13:01 ramonbakker