tag:blogger.com,1999:blog-1413304312041976659.post7745701452270847489..comments2023-10-06T00:30:56.122+11:00Comments on Christopher Hunt on Software Development: JavaScript Dependency Management and JSLint ToolsChristopherhttp://www.blogger.com/profile/06860404627954267472noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-1413304312041976659.post-58509420920409093662011-09-02T13:59:18.490+10:002011-09-02T13:59:18.490+10:00It should already do what you require...
You shou...It should already do what you require...<br /><br />You should be able to join the mailing list and specify the type of updates you want to receive (digest etc.). If you think there is a bug with the plugin then you can also post a JIRA e.g. http://jira.codehaus.org/browse/MOJO-1698<br /><br />(you need to prefix issues in the subject with [js-import-plugin] so that they are filtered correctly - once it goes 1.0 it'll get its own JIRA project).Christopherhttps://www.blogger.com/profile/06860404627954267472noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-80369363867001370172011-09-02T00:21:43.064+10:002011-09-02T00:21:43.064+10:00Sorry, it ate most of the XML.
Maybe I didn't...Sorry, it ate most of the XML.<br /><br />Maybe I didn't describe it very well. Suppose I were building foo.war; foo.pom declares a dependency on bar.jar; bar.pom declares a dependency on baz.jar. When I build foo.war, Maven automatically pulls in baz.jar even though I didn't declare it in foo.pom.<br /><br />I'd like to have a similar setup for JS where I only need to declare the direct dependency (bar.js) in the pom, and the plugin will look at the pom for bar.js and automatically pull in its dependency (baz.js).<br /><br />I'd be happy to post in a forum, but I don't really want to subscribe to a mailing list.Emphyriohttps://www.blogger.com/profile/02682843052387128777noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-90578093740783559602011-09-01T09:36:42.768+10:002011-09-01T09:36:42.768+10:00If baz.js needs to be imported by bar.js then it i...If baz.js needs to be imported by bar.js then it is a direct dependency, not a transitive dependency. Thus you would need to specify that your project depends on both bar.js and baz.js.<br /><br />It is great to have the feedback, but can I ask that you post to the Mojo users forum? To do this please subscribe to user-subscribe@mojo.codehaus.org. Thanks!Christopherhttps://www.blogger.com/profile/06860404627954267472noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-6302042745984020182011-09-01T07:58:51.935+10:002011-09-01T07:58:51.935+10:00Hi, I'm trying out your plugin, but I ran into...Hi, I'm trying out your plugin, but I ran into a problem with transitive dependencies. I have a file foo.html which includes foo.js, which imports bar.js, which imports baz.js. In foo.pom, I declare a dependency for bar.js. When I installed bar.js in my local Maven repo, I specified bar.pom which declares a dependency on baz.js. So it looks like the following:<br /><br />foo.html:<br /><script type="text/javascript" src="${foo.js}"></script><br /><br />foo.js:<br />/**<br /> * @import com.example.foo:bar<br /> */<br /><br />foo.pom:<br /><br /> com.example.foo<br /> bar<br /> 1.0<br /> js<br /><br /><br />bar.js:<br />/**<br /> * @import com.example.foo:baz<br /> */<br /><br />bar.pom:<br /><br /> com.example.foo<br /> baz<br /> 1.0<br /> js<br /><br /><br />However, during the main-import-js task, it threw an exception<br /><br />Caused by: org.apache.maven.plugin.MojoExecutionException: Build stopping given dependency issue.<br /> at org.codehaus.mojo.jsimport.AbstractImportMojo.processFileForImportsAndSymbols(AbstractImportMojo.java:842)<br /> at org.codehaus.mojo.jsimport.AbstractImportMojo.buildDependencyGraphForDependencies(AbstractImportMojo.java:458)<br /><br />I changed line 458 of AbstractImportMojo.java as follows:<br /><br />LinkedHashSet artifactTransitives = directArtifactWithTransitives.get( directArtifact );<br />if ( processFileForImportsAndSymbols( artifactFile, fileDependencyGraphModificationTime, artifactTransitives ) )<br /><br />This seems to have fixed the problem. Do you think this change would have any undesirable side effects?Emphyriohttps://www.blogger.com/profile/02682843052387128777noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-79143524281819410982011-06-21T15:18:20.305+10:002011-06-21T15:18:20.305+10:00I've not implemented that level of parsing sop...I've not implemented that level of parsing sophistication, but as I'm using ANTLR, it is not beyond the realms of possibility. Feel free to contribute to the project!<br /><br />What you can do though is:<br /><br />/*global my */<br /><br />or have an @import for the artifact that declares the GridView e.g.:<br /><br />/**<br /> * @import my.package.name:GridView <br /> */<br /><br />(not withstanding better naming as per GAV conventions in Maven)Christopherhttps://www.blogger.com/profile/06860404627954267472noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-78934092683485929192011-06-21T14:41:20.701+10:002011-06-21T14:41:20.701+10:00Wish I could edit comments... Essentially what I&#...Wish I could edit comments... Essentially what I'm asking is can I do<br /><br /> /*global my.package.name.GridView */ProggerPetehttps://www.blogger.com/profile/07372880048261703858noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-55044143506220547042011-06-21T14:40:12.806+10:002011-06-21T14:40:12.806+10:00Hmm, sounding interesting. The global bit might ge...Hmm, sounding interesting. The global bit might get me though. what if my GridView is actually declared as my.package.name.GridView? Does it still fly?ProggerPetehttps://www.blogger.com/profile/07372880048261703858noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-90779498882959758972011-06-21T11:45:20.830+10:002011-06-21T11:45:20.830+10:00But you can do that! :-)
You can a) either declar...But you can do that! :-)<br /><br />You can a) either declare what globals you require using the JSLint /*global ... */ convention; and/or b) declare the @import statements.<br /><br />For example if you have a GridView object declared in GridView.js, and then have /*global GridView */ in the top of your file that requires it, the plugin will ensure that GridView.js is brought in along with any of its dependencies.<br /><br />Kind regards,<br />ChristopherChristopherhttps://www.blogger.com/profile/06860404627954267472noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-92068525644216075062011-06-21T10:44:07.177+10:002011-06-21T10:44:07.177+10:00Hi Christopher,
Took a while to notice your respon...Hi Christopher,<br />Took a while to notice your response, was expecting an email.. Anyways, I get that I can import whole js artifacts. I was hoping to be more granular. E.g. I've got a project with no dependencies at all. I've got 50 odd js files, some of which depend on other js files inside my application.<br /><br />It would be handy to be able stick some import/requires type directive at the top of say, my GridView file and then just say. 'Give me GridView and any extra files it needs.<br /><br />Extending it further, once I've built this artifact I'd like to in another project depend on this artifact and again say, 'give me GridView'. Knowing that I'll get just enough of the js files to run it and no more.<br /><br />Cheers,<br />Peter<br /><br />Cheers,<br />PeteProggerPetehttps://www.blogger.com/profile/07372880048261703858noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-35225738357210875462011-06-12T20:19:49.327+10:002011-06-12T20:19:49.327+10:00Hi ProggerPete,
Yes, absolutely possible to impor...Hi ProggerPete,<br /><br />Yes, absolutely possible to import an artifact outside of using globals. To do this:<br /><br />/**<br /> * @import com.jqueryui:jquery-ui<br /> */<br /><br />Rather than using a class convention (there are no classes in JS!), we use a Maven group and artifact id. This will refer to a dependency declared in your pom.xml. <br /><br />Please also see the 3rd paragraph of the project page:<br /><br />http://mojo.codehaus.org/js-import-plugin/Christopherhttps://www.blogger.com/profile/06860404627954267472noreply@blogger.comtag:blogger.com,1999:blog-1413304312041976659.post-537763544512717602011-06-10T15:15:19.949+10:002011-06-10T15:15:19.949+10:00Hi Christopher,
I've wanted the same things an...Hi Christopher,<br />I've wanted the same things and am a reasonable way down the track of developing my own, similar, plugin.<br /><br />I'm not a big fan of doing work that someone else has already done though, so I'm having a look at your js import plugin.<br /><br />One query I have is whether it's possible to support non global vars? E.g. I'd like to use<br /><br />/**<br /> * @requires mypackage.MyClass<br /> */<br /><br />To import a specific file (and any dependencies of that file), as opposed to the whole artifact.ProggerPetehttps://www.blogger.com/profile/07372880048261703858noreply@blogger.com