Open chefhoobajoob opened 3 years ago
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
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
@chefhoobajoob I've started documenting the generation process here:
codegen does seem to be working from gradle with this setup:
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
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.
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:
...and apply that script in the project build script during evaluation so the system properties are available to the codegen task:
@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.
sure - i'll try to get one up and post the repo link here
hello world example project here: https://github.com/chefhoobajoob/es4x-codegen-gradle
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.