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

Transpilation problem with JSweet 3 #30

Open
shreyash-sharma opened this issue Jan 12, 2020 · 7 comments
Open

Transpilation problem with JSweet 3 #30

shreyash-sharma opened this issue Jan 12, 2020 · 7 comments

Comments

@shreyash-sharma
Copy link

I have added a custom jar as an external library to the jsweet-quickstart project in eclipse and imported it in the QuickStart.java file. While building the project using the command " mvn generate-sources" I am getting below errors:
[ERROR] Failed to execute goal org.jsweet:jsweet-maven-plugin:3.0.0-SNAPSHOT:jsweet (generate-js) on project jsweet-quickstart: transpilation failed: transpilation failed with 1 error(s) and 0 warning(s) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jsweet:jsweet-maven-plugin:3.0.0-SNAPSHOT:jsweet (generate-js) on project jsweet-quickstart: transpilation failed
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
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:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
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)
Caused by: org.apache.maven.plugin.MojoExecutionException: transpilation failed
at org.jsweet.AbstractJSweetMojo.transpile (AbstractJSweetMojo.java:632)
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:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
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)
Caused by: org.apache.maven.plugin.MojoFailureException: transpilation failed with 1 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:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
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)

Is there a way to fix this?

@lgrignon
Copy link
Collaborator

It seems that you have a transpilation error. Can you please identify and post here reported transpilation errors that you can find in logs before this stacktrace?

@shreyash-sharma
Copy link
Author

I believe this is the error you asked for, I'm sorry if I am mistaken :)

vibesimplejava is my jar and this is how I have added it in the pom.xml

		<dependency>
         <groupId>vibesimplejava</groupId>
         <artifactId>vibesimplejava</artifactId>
         <scope>system</scope>
         <version>1.6.0_45</version>
         <systemPath>D:\vibesimplejava.jar</systemPath>
      </dependency>
[INFO] candies detection: add project dependency Dependency {groupId=vibesimplejava, artifactId=vibesimplejava, version=1.6.0_45, type=jar} => vibesimplejava:vibesimplejava:jar:1.6.0_45:compile
Downloading from jsweet-snapshots: http://repository.jsweet.org/artifactory/libs-snapshot-local/vibesimplejava/vibesimplejava/1.6.0_45/vibesimplejava-1.6.0_45.pom
[INFO] Failure detected.
[ERROR] failed to create transpiler
org.apache.maven.artifact.resolver.ArtifactResolutionException: Unable to get dependency information for vibesimplejava:vibesimplejava:jar:1.6.0_45: Failed to retrieve POM for vibesimplejava:vibesimplejava:jar:1.6.0_45: Could not transfer artifact vibesimplejava:vibesimplejava:pom:1.6.0_45 from/to jsweet-snapshots (http://repository.jsweet.org/artifactory/libs-snapshot-local): Transfer failed for http://repository.jsweet.org/artifactory/libs-snapshot-local/vibesimplejava/vibesimplejava/1.6.0_45/vibesimplejava-1.6.0_45.pom 409 Conflict
  vibesimplejava:vibesimplejava:jar:1.6.0_45

@lgrignon
Copy link
Collaborator

Thanks, it helps!
I guess it comes from the system scoped dependency which is not properly handled by the JSweet maven mojo.
A quick fix should be to provide your jar as a compile dependency (hence publishing it to a maven repo, for instance your local repo).
There is currently no plan to support system dependency in jsweet -maven-plugin but it could be a good feature

@shreyash-sharma
Copy link
Author

Thank you for your reply.
Even after the compile dependency, I am unable to get it working.
But for now, I have run into a different issue and that is if I run the code on Eclipse everything runs fine but when running the mvn generate-sources command I am getting a NullPointerException.
Could you please give me some pointers for this.

[JCCompilationUnit] package com.run.secure... (D:\SAPI6\JSweet\jsweet-quickstart\src\main\java\quickstart\com\run\secure\enterprise\Context.java(5,1))
java.lang.NullPointerException        at org.jsweet.transpiler.Java2TypeScriptTranslator.doesMemberNameRequireQuotes(Java2TypeScriptTranslator.java:3471)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMemberSelect(Java2TypeScriptTranslator.java:3685)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMemberSelect(Java2TypeScriptTranslator.java:146)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2118)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
        at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269)
        at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.printDefaultNewClass(Java2TypeScriptTranslator.java:4648)
        at org.jsweet.transpiler.extension.Java2TypeScriptAdapter.substituteNewClass(Java2TypeScriptAdapter.java:1536)
        at org.jsweet.transpiler.extension.RemoveJavaDependenciesAdapter.substituteNewClass(RemoveJavaDependenciesAdapter.java:1659)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitNewClass(Java2TypeScriptTranslator.java:4582)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitNewClass(Java2TypeScriptTranslator.java:146)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1711)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
        at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269)
        at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitReturn(Java2TypeScriptTranslator.java:5009)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitReturn(Java2TypeScriptTranslator.java:146)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1554)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
        at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269)
        at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.printBlockStatement(Java2TypeScriptTranslator.java:3042)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.printBlockStatements(Java2TypeScriptTranslator.java:3035)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethod(Java2TypeScriptTranslator.java:2507)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethod(Java2TypeScriptTranslator.java:2217)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethod(Java2TypeScriptTranslator.java:146)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
        at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269)
        at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitClass(Java2TypeScriptTranslator.java:1746)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitClass(Java2TypeScriptTranslator.java:146)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
        at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269)
        at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitCompilationUnit(Java2TypeScriptTranslator.java:858)
        at org.jsweet.transpiler.Java2TypeScriptTranslator.visitCompilationUnit(Java2TypeScriptTranslator.java:146)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
        at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269)
        at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121)
        at org.jsweet.transpiler.JSweetTranspiler.generateTsFiles(JSweetTranspiler.java:880)
        at org.jsweet.transpiler.JSweetTranspiler.java2ts(JSweetTranspiler.java:843)
        at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:771)
        at org.jsweet.AbstractJSweetMojo.transpile(AbstractJSweetMojo.java:606)
        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:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/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)

@lgrignon
Copy link
Collaborator

This is interesting. Which version of the JSweet maven plugin are you using?
You should be using 3.0.0-RC1

What do you mean by "if I run the code on Eclipse": do you use JSweet Eclipse plugin or Maven from Eclipse?

This might be a bug in the last JSweet version, I will follow this carefuly.

@shreyash-sharma
Copy link
Author

shreyash-sharma commented Jan 15, 2020

Thank you again.
Version for jsweet-maven-plugin is 3.0.0-SNAPSHOT.
By running on eclipse I mean that I have a different project with the same structure as this Jsweet project.
So I was hoping to make changes and run the other project and reflect the same changes and build this Jsweet project.

The current Jsweet version that I cloned is built on Java 11, how do I clone the Jsweet repo for Java 8?

@lgrignon
Copy link
Collaborator

JSweet version 2.3.x is the recommended version for Java 8

Could you please post here your Context.java file so I could fix this bug in JSweet 3 which is about to be released?

Thanks for your help anyway

@lgrignon lgrignon changed the title Unable to build with Custom JAR added as external library Transpilation problem with JSweet 3 Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants