繁体   English   中英

CreateProcess error=206,运行gwtCompile时文件名或扩展名太长

[英]CreateProcess error=206, The filename or extension is too long when running gwtCompile

我的应用是springboot gradle应用。 我的应用程序的一部分涉及遗留 gwt 使用 gradle 编译。它工作正常但是今天当我运行下面的 gradle 任务时,它显示 CreateProcess error=206,文件名或扩展名太长。 可能出了什么问题? 因为它以前工作过。 对以下代码有任何建议的更改以解决此问题吗?

    task compileGwt(dependsOn: classes, type: JavaExec) {
    //ext.buildDir = "${project.buildDir}/resources/main/static"
    ext.buildDir = "${project.rootDir}/src/main/webapp"
    //ext.buildDir = "${project.buildDir}"
    ext.extraDir = "${project.buildDir}/extra"
    ext.generatedDir = "${project.buildDir}/generated"

    inputs.source sourceSets.main.java.srcDirs
    inputs.dir sourceSets.main.output.resourcesDir
    outputs.dir buildDir

    // Workaround for incremental build (GRADLE-1483)
    outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()

    doFirst {
        file(buildDir).mkdirs()
        //classpath.each { println it.name}
    }

    main = 'com.google.gwt.dev.Compiler'

    classpath {
        [
                sourceSets.main.java.srcDirs,           // Java source
                sourceSets.main.output.resourcesDir,    // Generated resources
                sourceSets.main.output.classesDir,      // Generated classes
                sourceSets.main.compileClasspath,       // Deps
        ]
    }

    args =
            [
                    'com.company.application.UI', // Your GWT module
                    '-war', buildDir,
                    '-logLevel', 'INFO',
                    '-style', 'DETAILED',
                    '-localWorkers', '2',
                    '-compileReport',
                    '-gen', generatedDir,
                    '-extra', extraDir,
                    '-draftCompile' // Speeds up compile with 25%
            ]
    maxHeapSize = '1024M'


}

war.dependsOn compileGwt
war {
    from compileGwt.buildDir
}

下面是带有 pathingJar 的更新后的 build.gradle,当我运行 compileGwt 时,它给出错误提示:Could not find or load main class com.google.gwt.dev.Compiler

apply plugin: "build-app"
apply plugin: 'war'
apply plugin: 'java'

dependencies {

    compile("javax.validation:validation-api:1.1.0.Final")
    compile("javax.validation:validation-api:1.1.0.Final:sources")
    compile("net.sourceforge.javacsv:javacsv:2.0")

    compile("org.springframework.boot:spring-boot-starter-security")
    compile("org.springframework.security:spring-security-ldap")
    compile("org.apache.directory.server:apacheds-server-jndi:1.5.5")
    compile("org.springframework:spring-web")
    compile("com.fasterxml.jackson.core:jackson-databind")

    compile("javax.servlet:javax.servlet-api:3.1.0")

    compile("com.google.gwt:gwt-user:2.5.1")
    compile("com.google.gwt:gwt-servlet:2.5.1")
    compile("com.google.gwt:gwt-dev:2.5.1")
    compile("com.google.gwt.inject:gin:1.5.0")

    compile("com.googlecode.mvp4g:mvp4g:1.4.0")
    compile("com.googlecode.mvp4g:mvp4g:1.4.0:sources")

    compile("com.sencha.gxt:gxt:3.0.1")
    compile("com.sencha.gxt:gxt:3.0.1:sources")


    compile("org.atmosphere:atmosphere-gwt-client:1.1.0.RC5")
    compile("org.atmosphere:atmosphere-gwt-server:1.1.0.RC5")
    compile("com.fasterxml.jackson.datatype:jackson-datatype-hibernate4:2.1.2")
    compile("org.bouncycastle:bcpg-jdk16:1.46")
    compile("org.jsoup:jsoup:1.7.2")
    compile("org.eclipse.jetty:jetty-continuation:9.3.5.v20151012")
    compile("org.springframework.boot:spring-boot-starter-aop")
    compile("com.googlecode.lambdaj:lambdaj:2.3.3")
    compile("org.apache.poi:poi:3.9")
    compile("org.apache.poi:poi-ooxml:3.9")
    compile("commons-fileupload:commons-fileupload:1.3.1")
    compile("org.springframework.security:spring-security-core:4.0.3.RELEASE")
    compile("com.google.guava:guava:18.0")
    compile("com.google.guava:guava-gwt:18.0")
    compile("org.springframework.integration:spring-integration-core:4.2.4.RELEASE")
    compile("org.samba.jcifs:jcifs:1.3.3")
    compile("org.springframework.integration:spring-integration-file:4.2.4.RELEASE")
    compile("org.springframework.integration:spring-integration-ftp:4.2.4.RELEASE")
    compile("org.springframework.integration:spring-integration-sftp:4.2.4.RELEASE")
    compile("org.springframework.integration:spring-integration-flow:1.0.0.RELEASE")
    compile("org.springframework.integration:spring-integration-java-dsl:1.1.0.M1")
    compile("org.atmosphere:wasync:2.1.2")

    compile libs.quartz
    compile libs.spring_jms
    compile libs.spring_jpa
    compile libs.jdbc_sybase

    runtime files("src/dist/conf")
    runtime files("src/dist/env/local")

    configurations {
        all*.exclude group: '', module: 'servlet-api'
    }
}

task createDirs << {
    sourceSets*.java.srcDirs*.each { it.mkdirs() }
    sourceSets*.resources.srcDirs*.each { it.mkdirs() }
    webAppDir.mkdirs()
}

task initProject << {
    File oldSource = file("./src")
    File tmpSource = file("./tmp")
    tmpSource.mkdirs()

    oldSource.listFiles().each { File f -> f.renameTo new File(tmpSource, f.name) }

    sourceSets*.java.srcDirs*.each { it.mkdirs() }
    sourceSets*.resources.srcDirs*.each { it.mkdirs() }
    webAppDir.mkdirs()

    File newSource = file(sourceSets.main.java.srcDirs.iterator().next())

    tmpSource.listFiles().each { File f -> f.renameTo new File(newSource, f.name) }

    tmpSource.delete()
}

task pathingJar(type: Jar) {
    dependsOn configurations.runtime
    appendix = 'pathing'

    doFirst {
        from "${project.buildDir}/classes"
        manifest {
            attributes "Class-Path": configurations.compile.files.join(" ")
        }
    }
}

task compileGwt(dependsOn: pathingJar, type: JavaExec) {

    //ext.buildDir = "${project.buildDir}/resources/main/static"
    ext.buildDir = "${project.rootDir}/src/main/webapp"
    //ext.buildDir = "${project.buildDir}"
    ext.extraDir = "${project.buildDir}/extra"
    ext.generatedDir = "${project.buildDir}/generated"

    inputs.source sourceSets.main.java.srcDirs
    inputs.dir sourceSets.main.output.resourcesDir
    outputs.dir buildDir

    // Workaround for incremental build (GRADLE-1483)
    outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()

    doFirst {
        file(buildDir).mkdirs()
        //classpath.each { println it.name}
    }


    main = 'com.google.gwt.dev.Compiler'
    classpath {
        [
                pathingJar.archivePath,
                sourceSets.main.java.srcDirs,           // Java source
                sourceSets.main.output.resourcesDir,    // Generated resources
                sourceSets.main.output.classesDir,      // Generated classes
                //sourceSets.main.compileClasspath,       // Deps

        ]
    }

    args =
            [
                    'com.company.application.UI', // Your GWT module
                    '-war', buildDir,
                    '-logLevel', 'INFO',
                    '-localWorkers', '2',
                    '-compileReport',
                    '-extra', extraDir,
                    // '-draftCompile' // Speeds up compile with 25%
            ]
    maxHeapSize = '1024M'


}

war.dependsOn compileGwt
war {
    from compileGwt.buildDir
}

我用这个 gradle 插件修复了一个类似的问题: https : //github.com/viswaramamoorthy/gradle-util-plugins

buildscript {
    dependencies {
        classpath "com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
    }
}
...
apply plugin: 'ManifestClasspath'

请参阅https://github.com/steffenschaefer/gwt-gradle-plugin/commit/087a94377fbd83cab938ffffe51ce8fab871be35 ,它对具有相同问题的 gwt-gradle-plugin 进行了修复。

您应该可以执行以下操作,而不是设置类路径

            if (System.getProperty("os.name").toLowerCase().contains("windows")) {
                javaExecSpec.environment("CLASSPATH", classpath.getAsPath());
            }

我根据修复长类路径的信息修复了这个问题

  1. 创建以下任务:

     task pathingJar(type: Jar) { dependsOn configurations.runtime appendix = 'pathing' doFirst { manifest { attributes "Class-Path": configurations.runtime.files.collect { it.toURL().toString().replaceFirst(/file:\\/+/, '/') }.join(' ') } }

    }

  2. 在 bootRun 中使用此任务

    task bootRunDev(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') { dependsOn pathingJar group = 'application' jvmArgs = [ "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n" ] doFirst() { main = bootJar.mainClassName classpath = files(sourceSets.main.output.files, pathingJar.archivePath) systemProperty 'spring.profiles.active', 'development' }

    }

我试图运行独立的 Java 程序。 在运行配置中更改以下内容修复了我的问题

在此处输入图片说明

这是在 gradle4.10 中工作的@GLK pathingJar解决方案的简化版本:

task pathingJar(type: Jar) {
    dependsOn configurations.runtimeClasspath
    appendix = 'pathing'

    doFirst {
        manifest {
            Set<File> classPathJars = configurations.runtimeClasspath.files
            attributes "Class-Path": classPathJars.collect {it.toURI().toURL().toString().replaceFirst("file:/", '/')}.join(" ")
        }
    }
}

bootRun {
    dependsOn pathingJar
    doFirst {
        classpath = files(sourceSets.main.output.files, pathingJar.archivePath)
    }
}

我的sourceSets.main.output.files (在 groovy 版本中)解析为: [<projectRoot>\build\classes\java\main, <projectRoot>\build\classes\groovy\main, <projectRoot>\build\resources\main]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM