NeoGradle icon indicating copy to clipboard operation
NeoGradle copied to clipboard

copyIdeResources not working in VSCode

Open WakelessSloth56 opened this issue 2 years ago • 2 comments

Processed resource files are in build/resources, but VSCode debugger uses the resources in bin directory, this causes the mods.toml cannot be parsed and fail to launch:

Exception in thread "main" com.electronwill.nightconfig.core.io.ParsingException: Invalid bare key: ${mod_id}

WakelessSloth56 avatar Sep 05 '23 06:09 WakelessSloth56

My temporary solution is:

  1. copyVSCodeResources task in build.gradle:

    task copyVSCodeResources (dependsOn: 'processResources', type: Copy) {
        from 'build/resources'
        into 'bin/'
    }
    
  2. preLaunchTask in launch.json:

    {
        "version": "0.2.0",
        "configurations": [
             {
                "type": "java",
                "name": "runClient",
                 // ...
                "preLaunchTask": "gradle: copyVSCodeResources"
            }
            // ...
        ]
    }
    

I think this could be integrated into the NeoGradle.

WakelessSloth56 avatar Sep 05 '23 06:09 WakelessSloth56

Facing the same issue, but I hack in using gradle eclipse model, although solution above seems a bit cleaner as it points to normal gradle processResources

eclipse {
    autoBuildTasks processResourcesEclipse
}

task processResourcesEclipse(type: Copy) {
    var buildPath = resolveEclipseBuildPath()

    from "$rootDir/src/main/resources/"
    into "$buildPath/main/"

    filesMatching ('**/mods.toml') {
        expand project.properties
    }
}

def resolveEclipseBuildPath() {
    var buildPath = eclipse.classpath.getDefaultOutputDir().toPath()
    if (buildPath.toString().endsWith("default")) {
        buildPath = buildPath.getParent()
    }
    return buildPath
}

Nightenom avatar Sep 09 '23 09:09 Nightenom

My temporary solution is:

  1. copyVSCodeResources task in build.gradle:
    task copyVSCodeResources (dependsOn: 'processResources', type: Copy) {
        from 'build/resources'
        into 'bin/'
    }
    
  2. preLaunchTask in launch.json:
    {
        "version": "0.2.0",
        "configurations": [
             {
                "type": "java",
                "name": "runClient",
                 // ...
                "preLaunchTask": "gradle: copyVSCodeResources"
            }
            // ...
        ]
    }
    

I think this could be integrated into the NeoGradle.

@marchermans only works by doing this on 7.0.150 i need to have "preLaunchTask": "gradle: copyVSCodeResources" to make it work but everytime i launch the game and save a file. it overwrites the launch.json file and removes that

Anonymous2416 avatar Jun 25 '24 21:06 Anonymous2416