cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 160 forks source link

no Java candy example #616

Closed vorth closed 3 years ago

vorth commented 3 years ago

I'm loving JSweet so far, for the most part, but...

I cannot see how to pull in the Java candies from your Artifactory to my project. Initially, I would see errors like this:

2020-08-28 13:54:35.035 ERROR output:55 - package com.fasterxml.jackson.databind does not exist at /Users/vorth/vZome/vzome-all/core/src/main/java/com/vzome/unity/Adapter.java(12)
2020-08-28 13:54:35.035 ERROR JSweetTranspiler:95 - /Users/vorth/vZome/vzome-all/core/src/main/java/com/vzome/unity/Adapter.java:12: error: package com.fasterxml.jackson.databind does not exist
import com.fasterxml.jackson.databind.JsonNode;

I added the pom.xml dependencies, e.g.

   <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.9.7</version>
   </dependency>

...using versions I found in your Artifactory.

Now, I get through the Java transpiler, but I'm failing (apparently) in the Typescript transpiler, with hundreds of errors like this:

2020-08-28 13:58:17.017 ERROR output:55 - namespace 'com' has no exported member 'fasterxml' at /Users/vorth/vZome/vzome-all/core/src/main/java/com/vzome/core/render/JsonMapper.java(36)
2020-08-28 13:58:17.017 INFO  TypeScript2JavaScriptWithTscTranspiler:94 - com/vzome/core/render/JsonMapper.ts(132,70): error TS2694: Namespace 'com' has no exported member 'fasterxml'.

Furthermore, there is no evidence, either in .jsweet/candies or in webapp/candies, that the Jackson candies have actually been downloaded. What am I missing? (Yes, I have added repositories for jsweet-central and jsweet-snapshots... pom.xml attached.)

Perhaps I'm picking up artifacts from Maven Central, implicitly?

In any case, it would be really helpful if you provided an example that pulls Java candies from Artifactory.

pom.xml.zip

vorth commented 3 years ago

Furthermore, I dug out the Jackson JAR that Maven downloaded... I don't think this is a candy at all. There is no TypeScript code, nothing but the usual .class files.

I think I see what is happening... when I searched Artifactory, my search somehow fell through into external, non-jsweet repositories. There are no candies for Jackson.

Even so, I'd still like to see a Java candy example.

renaudpawlak commented 3 years ago

As you found out, com.fasterxml.jackson.core group is a regular Java lib. It cannot be a candy. Everything is explained here: http://www.jsweet.org/jsweet-candies/ Basically, you have 2 kinds of candies:

Candies of the second kind require extra development... it is not alway possible to create a candy that will support a Java library. You will find the Java candies state-of-the-art in the https://github.com/j4ts organization.

As for an example, a Java candy is used exactly like a regular JavaScript candy... if it does not work, it means that there is a bug somewhere :)

lgrignon commented 3 years ago

Thanks @vorth and @renaudpawlak for the answer.

@vorth do you now have everything you need? Please close this issue if it's a yes :)

lgrignon commented 3 years ago

This is now up to date with latest JSweet https://github.com/lgrignon/jsweet-candy-example :)

vorth commented 3 years ago

Thank you, @lgrignon. That helps.

I still have a number of questions, and I don't want to raise defects. I would really appreciate it if you or @renaudpawlak could email me. I have been very successful so far (see https://vzome.com/app), but I want to go to the next level and package my code as a React component on NPM. I cannot ask people to add script tags to their index.html as I have. My email address is on my profile.