0

编辑:输入编译器失败,这就是错误代码。

首先要做的事情:对于大量的 WallOfCode 感到抱歉,我试图提供我所拥有的所有信息。

嘿,这是我第一次来这里。我会尽我所能描述我的问题。我创建了一个 Maven 多项目,有 2 个模块。TestA 中的 TestA 和 TestB 是我以后 JS 转换的主要内容。TestB 中有 2 个类,一个用于方法:

public String foo (String s, String t) {
    Exchange ex = new Exchange( s.trim(), t.trim() );
}

一个用于缓存,但我们现在可以忘记这一点。

如果 TestA 从 foo (TestB) 生成一个对象并将其用于一个简单的 sout 我得到了一个错误。如果 TestA 从 TestA 中的方法生成一个对象并将其用于一个简单的 sout 它就可以工作。

我想我无法与第二个模块 TestB 类取得联系。

我从 java 到 javascript 代码的转换适用于在我的 TestA 类中使用方法

希望有人可以帮助我,挣扎几天。

这里有一些代码:

我的 POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>de.binarium</groupId>
    <artifactId>archetype</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>TestB</module>
        <module>TestA</module>
    </modules>

    <properties>
        <jsweet.transpiler.version>3.0.0-SNAPSHOT</jsweet.transpiler.version>
        <jsweet.core.version>6.0.2</jsweet.core.version>
        <java.version.release>11</java.version.release>
        <java.version>1.${java.version.release}</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>




    <repositories>
        <repository>
            <id>jsweet-central</id>
            <name>libs-release</name>
            <url>http://repository.jsweet.org/artifactory/libs-release-local</url>
        </repository>

    </repositories>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>${java.version.release}</release>
                    <compilerVersion>${java.version}</compilerVersion>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jsweet</groupId>
                <artifactId>jsweet-maven-plugin</artifactId>
                <version>${jsweet.transpiler.version}</version>
                <configuration>
                    <verbose>true</verbose>
                    <tsOut>target/reneTs</tsOut>
                    <outDir>target/renejs</outDir>
                    <candiesJsOut>webapp</candiesJsOut>
                    <targetVersion>ES6</targetVersion>
                    <moduleResolution>classic</moduleResolution>

                    <includes>
                        <include>**/*.java</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-js</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>jsweet</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>
    <dependencies>

        <dependency>
            <groupId>org.jsweet.candies</groupId>
            <artifactId>jquery</artifactId>
            <version>1.10.0-20170726</version>
        </dependency>
    </dependencies>


</project>

我的测试A

package main.java.app.momente;
import main.java.TestB;
import java.io.IOException;


public class TestA {

  public static void main( String[] args ) throws IOException {

    System.out.println("Hallo, welt");


  }
}

我的测试B

package main.java;



public class TestB {


  public String foo (String s, String t){
    Exchange ex = new Exchange( s.trim(), t.trim() ); // The Exchange methode is correct, no need to investigate


    String outT = ex.t;
    String outS = ex.s;

    return ex.s + ex.t;
  }
}

最后我的代码来自 mvn generate-sources

[ERROR] transpilation failed
org.apache.maven.plugin.MojoFailureException: transpilation failed with 2 error(s) and 0 warning(s)
    at org.jsweet.AbstractJSweetMojo.transpile (AbstractJSweetMojo.java:618)
    at org.jsweet.JSweetMojo.execute (JSweetMojo.java:43)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.915 s
[INFO] Finished at: 2020-01-09T15:15:13+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jsweet:jsweet-maven-plugin:3.0.0-SNAPSHOT:jsweet (generate-js) on project TestA: transpilation failed: transpilation failed with 2 error(s) and 0 warning(s) -> [Help 1]
4

0 回答 0