pom file parent project
Closed this issue · 18 comments
Hi
I have following maven structure
parent-project
|-jsweet-project
if I do following :
cd parent-project
mvn clean install
jsweet use parent-project as current directory instead of parent-project\jsweet-project
So all jsweet generated files will be created under parent project. Also "jsweetconfig.json" file is tried to be resolve under paren directory
Partially I have resolve the issue by following configuration
<plugin>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-maven-plugin</artifactId>
<version>${version.jsweet.transpiler}</version>
<executions>
<execution>
<id>generate-js</id>
<phase>generate-sources</phase>
<goals>
<goal>jsweet</goal>
</goals>
<configuration>
<verbose>true</verbose>
<outDir>${project.basedir}/src/main/resources/META-INF/resources/webjars/${project.artifactId}/${project.version}</outDir>
<dtsOut>${project.basedir}/src/main/resources/META-INF/resources/typings/${project.artifactId}/${project.version}</dtsOut>
<tsOut>${project.basedir}/target</tsOut>
<workingDir>${project.basedir}</workingDir>
<declaration>true</declaration>
<sourceMap>true</sourceMap>
<targetVersion>ES6</targetVersion>
<module>es2015</module>
</configuration>
</execution>
</executions>
</plugin>
But I cannot configure location of "jsweetconfig.json" file
Thanks
Arseniy Isakov
Note: version of the plugin 2.0.1-SNAPSHOT
Hi
No it is not working. I have configuration file and customization adapter inside of jsweet-project.
During maven execution jsweet cannot find Adapter.
Thanks
Arseniy Isakov
Hi,
Could you provide the stacktrace please?
I will give a look now
If you could also give me the result of this print please:
cincheo/jsweet@d1123fa
2017-10-03 06:53:31.031 INFO JSweetFactory:64 - constructing adapters: [org.tura.jsweet.TsAdapter]
[ERROR] transpilation failed
java.lang.RuntimeException: java.lang.ClassNotFoundException: org.tura.jsweet.TsAdapter
at org.jsweet.transpiler.JSweetFactory.createAdapter(JSweetFactory.java:113)
at org.jsweet.transpiler.JSweetTranspiler.initJavac(JSweetTranspiler.java:589)
at org.jsweet.transpiler.JSweetTranspiler.setupCompiler(JSweetTranspiler.java:902)
at org.jsweet.transpiler.JSweetTranspiler.java2ts(JSweetTranspiler.java:1000)
at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:983)
at org.jsweet.AbstractJSweetMojo.transpile(AbstractJSweetMojo.java:445)
at org.jsweet.JSweetMojo.execute(JSweetMojo.java:41)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ClassNotFoundException: org.tura.jsweet.TsAdapter
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.jsweet.transpiler.JSweetFactory.createAdapter(JSweetFactory.java:71)
... 28 more
This is log from maven
log.txt
Indeed, this bug remained unfix. It should be ok by now through e9774f8931a5d4ca4d692b48704fdb27a1936418 and 89aa3788744dcd3819636c1fca735348cff37276
I just deployed it to 2.0.1-SNAPSHOT, could you please give a try?
No still is not working
Class JSweetTranspiler
Line 501
Use following
new ExtensionManager(baseDirectory.getAbsolutePath() + File.separator + JSweetConfig.EXTENSION_DIR).checkAndCompileExtension(this.workingDir, classPath);
Fixed with 5ea287763c103a6a2137a755dfa0aa3c6da82763
and deployed to 2.0.1-SNAPSHOT
I hope it's the last occurrence :)
Still an issue.
I have figured out. Problem in ExtensionManager
Variable "foundExtension" always false. It is never updates class path.
If I change code to force class path update jsweet is working,
private void initExtensionClassPath() {
if (!extensionDir.exists()) {
return;
}
try {
if (!(PrinterAdapter.class.getClassLoader() instanceof URLClassLoader)) {
throw new RuntimeException(
"local extensions are not supported in this environment, please use a packaged extension");
}
URLClassLoader urlClassLoader = (URLClassLoader) PrinterAdapter.class.getClassLoader();
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
boolean foundExtension = false;
for (URL url : urlClassLoader.getURLs()) {
if (url.getPath().endsWith("/" + JSweetConfig.EXTENSION_DIR)) {
foundExtension = true;
break;
}
}
if (!foundExtension) {
method.invoke(urlClassLoader, new File(JSweetConfig.EXTENSION_DIR).toURI().toURL());
logger.debug("updated classpath with: " + new File(JSweetConfig.EXTENSION_DIR).toURI().toURL());
}
} catch (Exception e) {
throw new RuntimeException("fail to initalize extension classpath", e);
}
}
So method will be like this
private void initExtensionClassPath() {
if (!extensionDir.exists()) {
return;
}
try {
if (!(PrinterAdapter.class.getClassLoader() instanceof URLClassLoader)) {
throw new RuntimeException(
"local extensions are not supported in this environment, please use a packaged extension");
}
URLClassLoader urlClassLoader = (URLClassLoader) PrinterAdapter.class.getClassLoader();
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(urlClassLoader, this.extensionDir.toURI().toURL());
logger.debug("updated classpath with: " + this.extensionDir.toURI().toURL());
} catch (Exception e) {
throw new RuntimeException("fail to initalize extension classpath", e);
}
}
Is it possible that you share your project or a similar one on a Github I could clone? If not possible, I will try to create a sample project for JSweet with maven parent pom and fix all remaining problems
This is link on my project https://github.com/isakovarseniy/tura . You need switch to version 4.3.0.
>cd platform/platform-ts/
>mvnDebug clean install
if you run mvnDebug you can connect with remote debugger Or you can run just
>mvn clean install
Hello @isakovarseniy I just deployed a new version of JSweet, with which I succeeded to build your project. I had some remaining errors in your unit tests runs but I think this is not related, please tell me if you think this way as well.
By the way, you were right, it was more of a JSweet issue than a JSweet maven plugin's issue ;)
Please close if ok for you
Thanks It works
So what is the solution to this. I am getting the exact same error described here. My pluggin version looks like that
<plugin>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-maven-plugin</artifactId>
<!-- <version>2.0.0-rc1</version> -->
<version>2.0.1-SNAPSHOT</version>
<configuration>
<sourceMap>true</sourceMap>
<declaration>true</declaration>
<outDir>target/js</outDir>
<dtsOut>target/ts</dtsOut>
<workingDir>${project.basedir}</workingDir>
<verbose>true</verbose>
<!-- Do not compile the TypeScript output (let an external TypeScript compiler do so). -->
<tsOnly>false</tsOnly>
<excludes>
</excludes>
<targetVersion>ES6</targetVersion>
<module>es2015</module>
<bundle>false</bundle>
<executions>
<execution>
<id>generate-js</id>
<phase>generate-sources</phase>
<goals>
<goal>jsweet</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
and I am currenly using those two version. lgrignon can you please share what did you do in order to fix the error.
<dependency>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-core</artifactId>
<version>5-20170726</version>
</dependency>
<dependency>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-transpiler</artifactId>
<version>2.0.1-SNAPSHOT</version>
</dependency>
I have the exact same project strurcture as the one described here Configure path to jsweetconfig.json and jsweet_extension but i still getting the same error. my jsweetconfig.json looks like
{
adapters: [ "ByteBufferAdapter", "TimeAdapter"]
}
Remove extension.json file.
Remove ByteBufferAdapter.class, TimeAdapter.class
Thanks @isakovarseniy
@courteous does it work for you?
i have commented the following lines in my pom and then it started working agian
<!-- <workingDir>${project.basedir}</workingDir> -->
<!-- <tsOut>${project.basedir}/target</tsOut> -->
simply removing the adapters and extension.json file did not worked for me.