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

Need migration guide documentation for moving vertx 3 js verticles to es4x #554

Open
chefhoobajoob opened this issue Sep 9, 2021 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@chefhoobajoob
Copy link

The vert.x 3 libraries made use of vertx-lang-js wrapper scripts in order to make vert.x libs accessible to js verticles. We also have some of our own "polyglot" class libraries that used that same scheme via codegen for using our own vertx utility libraries from js.

Assuming there is an analogous mechanism in es4x for using vert.x and/or custom libs that were using the vertx 3 vertx-lang-js wrappers, it would be extremely helpful if there was guidance documentation describing how to migrate such js code over to es4x.

@chefhoobajoob chefhoobajoob changed the title Need migration guide material for moving vertx 3 js verticles to es4x Need migration guide documentation for moving vertx 3 js verticles to es4x Sep 9, 2021
@pmlopes pmlopes self-assigned this Sep 9, 2021
@pmlopes pmlopes added the enhancement New feature or request label Sep 9, 2021
@chefhoobajoob
Copy link
Author

chefhoobajoob commented Sep 9, 2021

Not exactly the same topic, but related: it would be good to know how to package up an es4x project as a verticle "library" (not an app) to be loaded from java running on the jvm via the verticle factory, classpath requirements, etc. Like, for the vert.x 3 world, we had to ensure js directories were on the classpath and had to ensure NODE_PATH was defined so require statements could find dependencies. I'm sure there are differences there too. I've got bits and pieces on what to do from gitter convos, but there's not really much on this setup at reactiverse.io

@pmlopes
Copy link
Contributor

pmlopes commented Sep 10, 2021

I've noticed that 've been missing some artifacts during the release. I'm working on the documentation of the process, but for now assume you can do anything like this (using maven, but can use gradle too):

<?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">

  <parent>
    <groupId>io.reactiverse.es4x</groupId>
    <artifactId>es4x-generator</artifactId>
    <version>0.15.1-SNAPSHOT</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>

  <artifactId>vertx-redis-client</artifactId>  <!-- <<<- here the java artifact you want to convert -->
  <version>1.0.0</version>

  <properties>
    <maven.groupId>io.vertx</maven.groupId>              <!-- <<<- here the java artifact group you want to convert -->
    <npm-name>@vertx/redis-client</npm-name>  <!-- <<<- here the npm desired package name -->
    <npm-version>4.1.3</npm-version>         <!-- <<<- here the java version you want to convert -->
    <npm-skip>false</npm-skip>

    <!-- language=json -->    <!-- <<<- any customization to package.json you want, but this is required -->
    <package-json>
      {
        "description": "${project.description}",
        "version": "${npm-version}",
        "license": "${npm-license}",
        "maven": {
          "groupId": "io.vertx",
          "artifactId": "vertx-redis-client",
          "version": "${npm-version}"
        }
      }
    </package-json>
  </properties>

  <dependencies>
    <!-- Sources to process -->
    <dependency>
      <groupId>${maven.groupId}</groupId>
      <artifactId>${project.artifactId}</artifactId>
      <version>${npm-version}</version>
    </dependency>
    <dependency>
      <groupId>${maven.groupId}</groupId>
      <artifactId>${project.artifactId}</artifactId>
      <version>${npm-version}</version>
      <scope>provided</scope>
      <classifier>sources</classifier>
    </dependency>
  </dependencies>

</project>

Running a mvn generate-sources should finish with a target/npm folder with your generated npm package you can later upload to npm or your local repository

@pmlopes
Copy link
Contributor

pmlopes commented Sep 10, 2021

@chefhoobajoob I've started documenting the generation process here:

4c9df86#diff-2586b42924f021fe14c65861d3404f4b4015ee68c6592ce5633fee850940b470

@chefhoobajoob
Copy link
Author

chefhoobajoob commented Sep 10, 2021

codegen does seem to be working from gradle with this setup:

image

image

I get an npm folder in <project-root>/src/main with package.json and the other expected files. Just need to figure out how to get dependencies and other properties configured

@pmlopes
Copy link
Contributor

pmlopes commented Sep 11, 2021

If you look at the manual I've started, there's a lot of system properties in the maven snippet I've added. You will need to pass those environmental variables to the process running the annotation processor.

@chefhoobajoob
Copy link
Author

chefhoobajoob commented Sep 11, 2021

Yes, was referring to those examples - thank you. I setup the gradle equivalent as a separate build script (es4x-codegen.gradle) where the es4x codegen system properties for the build can be managed, like so:

image

...and apply that script in the project build script during evaluation so the system properties are available to the codegen task:
image

@pmlopes
Copy link
Contributor

pmlopes commented Sep 13, 2021

@chefhoobajoob can you share a simple hello world with your gradle script? I think we can improve it to be an easy template to generate es4x packages.

@chefhoobajoob
Copy link
Author

sure - i'll try to get one up and post the repo link here

@chefhoobajoob
Copy link
Author

hello world example project here:
https://github.com/chefhoobajoob/es4x-codegen-gradle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants