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

pom file parent project #37

Closed
isakovarseniy opened this issue Sep 25, 2017 · 18 comments
Closed

pom file parent project #37

isakovarseniy opened this issue Sep 25, 2017 · 18 comments
Assignees
Labels
Milestone

Comments

@isakovarseniy
Copy link

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

@lgrignon lgrignon self-assigned this Oct 1, 2017
@lgrignon lgrignon added the bug label Oct 1, 2017
@lgrignon lgrignon added this to the 2.0.1 milestone Oct 1, 2017
@lgrignon
Copy link
Owner

lgrignon commented Oct 2, 2017

Fixed through 77536a0

Could you please try again and close? Thanks

@lgrignon
Copy link
Owner

lgrignon commented Oct 2, 2017

Note: version of the plugin 2.0.1-SNAPSHOT

@isakovarseniy
Copy link
Author

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

@lgrignon
Copy link
Owner

lgrignon commented Oct 3, 2017

Hi,
Could you provide the stacktrace please?
I will give a look now

@lgrignon
Copy link
Owner

lgrignon commented Oct 3, 2017

If you could also give me the result of this print please:
cincheo/jsweet@d1123fa

@isakovarseniy
Copy link
Author

isakovarseniy commented Oct 3, 2017

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

@lgrignon
Copy link
Owner

lgrignon commented Oct 3, 2017

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?

@isakovarseniy
Copy link
Author

isakovarseniy commented Oct 3, 2017

No still is not working

Class JSweetTranspiler
Line 501
Use following

		new ExtensionManager(baseDirectory.getAbsolutePath() + File.separator + JSweetConfig.EXTENSION_DIR).checkAndCompileExtension(this.workingDir, classPath);

@lgrignon
Copy link
Owner

lgrignon commented Oct 4, 2017

Fixed with 5ea287763c103a6a2137a755dfa0aa3c6da82763
and deployed to 2.0.1-SNAPSHOT

I hope it's the last occurrence :)

@isakovarseniy
Copy link
Author

isakovarseniy commented Oct 4, 2017

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);
		}
	}

@lgrignon
Copy link
Owner

lgrignon commented Oct 5, 2017

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

@isakovarseniy
Copy link
Author

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

@lgrignon
Copy link
Owner

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

@isakovarseniy
Copy link
Author

Thanks It works

@courteous
Copy link

courteous commented Nov 16, 2017

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"]
}

@isakovarseniy
Copy link
Author

Remove extension.json file.
Remove ByteBufferAdapter.class, TimeAdapter.class

@lgrignon
Copy link
Owner

Thanks @isakovarseniy

@courteous does it work for you?

@courteous
Copy link

courteous commented Nov 19, 2017

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.

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

No branches or pull requests

3 participants