You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jacob Beard <jb...@cs.mcgill.ca> on 2010/08/26 04:44:37 UTC

downloading JavaScript libraries

Hi,

My project includes dependencies on several JavaScript libraries, 
including Dojo, RequireJS and beautify-js. I'm currently using Ant's get 
task to download these dependencies, but I'd like to integrate this with 
my Maven build. The way I thought I would do this would be to bind an 
antrun goal to the phase in which dependencies are downloaded. However, 
after consulting the lifecycle reference 
<http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference>, 
I cannot find a Maven phase in which dependencies are downloaded.

Please let me know if I'm on the right track, or if there is a better 
way of going about this. Thanks,

Jake

Re: downloading JavaScript libraries

Posted by Jacob Beard <jb...@cs.mcgill.ca>.
Manos,

Thanks for the reply. This makes good sense to me.

Jake

On 10-08-26 10:54 AM, Manos Batsis wrote:
> On 08/26/2010 05:44 AM, Jacob Beard wrote:
>> My project includes dependencies on several JavaScript libraries,
>> including Dojo, RequireJS and beautify-js. I'm currently using Ant's get
>> task to download these dependencies, but I'd like to integrate this with
>> my Maven build. The way I thought I would do this would be to bind an
>> antrun goal to the phase in which dependencies are downloaded. However,
>> after consulting the lifecycle reference
>> <http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference>, 
>>
>> I cannot find a Maven phase in which dependencies are downloaded.
>
> If those are dependencies native to Maven they will be downloaded 
> automatically from the central repository or a repository you specify.
>
> If however by "dependencies" you just mean your project depends on 
> them and they are not available in the maven repo (you can check for 
> example using [1]) then using antrun will be fine. If you just need to 
> package them along with everything else choose any phase before 
> "p[ackage" (e.g. "prepare-package"). If you want to do more stuff with 
> them (i remember you do some JS pre-compile to jave stuff?) then fetch 
> them during "generate-sources" or something.
>
> hth,
>
> Manos
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: downloading JavaScript libraries

Posted by Manos Batsis <ma...@geekologue.com>.
On 08/26/2010 05:54 PM, Manos Batsis wrote:
> On 08/26/2010 05:44 AM, Jacob Beard wrote:
>> My project includes dependencies on several JavaScript libraries,
>> including Dojo, RequireJS and beautify-js. I'm currently using Ant's get
>> task to download these dependencies, but I'd like to integrate this with
>> my Maven build. The way I thought I would do this would be to bind an
>> antrun goal to the phase in which dependencies are downloaded. However,
>> after consulting the lifecycle reference
>> <http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference>,
>>
>> I cannot find a Maven phase in which dependencies are downloaded.
>
> If those are dependencies native to Maven they will be downloaded
> automatically from the central repository or a repository you specify.

Forgot to say that, for this to work, you will need to add them as 
dependencies in your POM.


> If however by "dependencies" you just mean your project depends on them
> and they are not available in the maven repo (you can check for example
> using [1]) then using antrun will be fine. If you just need to package
> them along with everything else choose any phase before "p[ackage" (e.g.
> "prepare-package"). If you want to do more stuff with them (i remember
> you do some JS pre-compile to jave stuff?) then fetch them during
> "generate-sources" or something.
>
> hth,
>
> Manos
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: downloading JavaScript libraries

Posted by Manos Batsis <ma...@geekologue.com>.
On 08/26/2010 05:44 AM, Jacob Beard wrote:
> My project includes dependencies on several JavaScript libraries,
> including Dojo, RequireJS and beautify-js. I'm currently using Ant's get
> task to download these dependencies, but I'd like to integrate this with
> my Maven build. The way I thought I would do this would be to bind an
> antrun goal to the phase in which dependencies are downloaded. However,
> after consulting the lifecycle reference
> <http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference>,
> I cannot find a Maven phase in which dependencies are downloaded.

If those are dependencies native to Maven they will be downloaded 
automatically from the central repository or a repository you specify.

If however by "dependencies" you just mean your project depends on them 
and they are not available in the maven repo (you can check for example 
using [1]) then using antrun will be fine. If you just need to package 
them along with everything else choose any phase before "p[ackage" (e.g. 
"prepare-package"). If you want to do more stuff with them (i remember 
you do some JS pre-compile to jave stuff?) then fetch them during 
"generate-sources" or something.

hth,

Manos

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven community maintaining popular JS lib deps? (was: Re: downloading JavaScript libraries)

Posted by Jesse Farinacci <ji...@gmail.com>.
Greetings,

On Thu, Aug 26, 2010 at 12:53 PM, Manos Batsis
<ma...@geekologue.com> wrote:
>
> The only reason to package those javascript files in JARs and upload them to
> the maven central repo is for other projects to reuse them as dependencies.
> I don't think this is your case.

This definitely wasn't what he asked to do, and you were right to
answer him directly. I answered the question that I think he *should*
have asked.. ;-) Perhaps complicating things far too much..

> On the other hand and since most javascript projects do not produce maven
> dependencies for the maven users out there, it might make sense to establish
> a community in this list to maintain popular JS lib dependencies.
>
> Some questions to list members:
>
>  - Does it sound like a good idea and why?
>  - How should we go for it in organizing a team of maintainers?
>  - How should those JS libs packaged?

There's already a javascript project on codehaus[1], I am surprised
that they do not already publish Maven artifacts for popular
frameworks. I'd recommend publish them in a variety of formats:

 * maven-remote-resource-bundle
 * jar
 * war

The first could be used to seed the second and third. Let the users
choose for themselves which works best for them..

-Jesse

[1] http://mojo.codehaus.org/javascript-maven-tools/

-- 
There are 10 types of people in this world, those
that can read binary and those that can not.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Maven community maintaining popular JS lib deps? (was: Re: downloading JavaScript libraries)

Posted by Manos Batsis <ma...@geekologue.com>.
On 08/26/2010 06:51 PM, Jacob Beard wrote:
> On 10-08-26 11:27 AM, Jesse Farinacci wrote:
>> Making them proper Maven modules and populating them ONE time manually
>> when you create the artifact would enable all of your users to
>> automatically download the artifact which contains the javascript
>> library.
>
> I think this is where my comprehension is breaking down. In order for
> other users to automatically download these new JavaScript library
> modules that I would create, would these new modules need to be
> published in a Maven repository? Or is there another mechanism involved
> in distributing these libraries?

The only reason to package those javascript files in JARs and upload 
them to the maven central repo is for other projects to reuse them as 
dependencies. I don't think this is your case.

On the other hand and since most javascript projects do not produce 
maven dependencies for the maven users out there, it might make sense to 
establish a community in this list to maintain popular JS lib dependencies.

Some questions to list members:

  - Does it sound like a good idea and why?
  - How should we go for it in organizing a team of maintainers?
  - How should those JS libs packaged?

Especially for the latter, i think some people use WAR overlays, others 
like me use JARs and resource loading and there may even be other ways. 
The packaging should be usable for both common and web applications.

Another thing is a)versioning and b)alternatives for the same file. What 
we do here at abiss is:

  - Versioning: the browser always makes a request for (e.g.) 
"/resources/gr/abiss/js/sarissa.js" and our maven-jstools-plugin [1] 
servlet filter [2]loads the script version that was included as a POM 
dependency.
  - Alternative versions of the same file like compressed/minified are 
loaded based on convension e.g. sarissa.js sarissa-min.js

Other of course may have better ideas for the table, but overall it may 
be a good time to establish at least a community of dep maintainers for 
popular JS libs.

[1] http://dev.abiss.gr/mvn-jstools/
[2] 
http://dev.abiss.gr/mvn-jstools/apidocs/gr/abiss/mvn/plugins/jstools/web/JavascriptDependencyFilter.html

Cheers,

Manos


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: downloading JavaScript libraries

Posted by Jesse Farinacci <ji...@gmail.com>.
Hi Jake,

On Thu, Aug 26, 2010 at 11:51 AM, Jacob Beard <jb...@cs.mcgill.ca> wrote:
>
> I think this is where my comprehension is breaking down. In order for other
> users to automatically download these new JavaScript library modules that I
> would create, would these new modules need to be published in a Maven
> repository? Or is there another mechanism involved in distributing these
> libraries?

I think you're getting it now! No worries :-) Ok, yes, you would
create these artifacts yourself and then publish them. You probably
would not have any luck getting them into Maven central so you'd want
a Maven Repository Manager (MRM) available. There are a few which are
freely available, I would recommend Nexus[1] or Archiva[2]; but
there's an alternate means if you do not want to go through the very
limited hassle.

You could also create a file system which is in the right format of a
Maven repository. Then you could just use mvn deploy to push them to
that file system using scp, e.g. Then your web server would sort of
act like an MRM of limited scope. It'd probably be easier to just set
up one of the aforementioned MRMs and be done with it.

> Thanks for your patience in explaining this issue,

You're picking it up quick, so that's always positive!
-Jesse

[1] http://nexus.sonatype.org/download-nexus.html
[2] http://archiva.apache.org/download.html

-- 
There are 10 types of people in this world, those
that can read binary and those that can not.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: downloading JavaScript libraries

Posted by Jacob Beard <jb...@cs.mcgill.ca>.
Hi Jesse,

On 10-08-26 11:27 AM, Jesse Farinacci wrote:
> Making them proper Maven modules and populating them ONE time manually
> when you create the artifact would enable all of your users to
> automatically download the artifact which contains the javascript
> library.

I think this is where my comprehension is breaking down. In order for 
other users to automatically download these new JavaScript library 
modules that I would create, would these new modules need to be 
published in a Maven repository? Or is there another mechanism involved 
in distributing these libraries?

Thanks for your patience in explaining this issue,

Jake

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: downloading JavaScript libraries

Posted by Jesse Farinacci <ji...@gmail.com>.
Greetings,

On Thu, Aug 26, 2010 at 10:54 AM, Jacob Beard <jb...@cs.mcgill.ca> wrote:
>
> I'm new to Maven, and so I don't completely understand your answer. Why
> would it be desirable to create a module for each JavaScript library in this
> context, especially as this will not facilitate their automated downloading?

It would be desirable because your project has a dependency which is
not part of the Maven ecosystem. Your project managing the download of
dependencies is the antithesis of one of Maven's best features....

Making them proper Maven modules and populating them ONE time manually
when you create the artifact would enable all of your users to
automatically download the artifact which contains the javascript
library.

> Also, it still seems like it would be desirable to instruct maven to
> automatically download these libraries, so that they will not need to be
> downloaded manually. Is there no way to instruct Maven to do this?

Maven doesn't do well, nor was it designed to do well, with managing
non-Maven artifacts. And this is what you're asking it to do. I also
think you seem to be confusing Maven downloading a Maven artifact
dependency and you downloading some javascript library which is not a
Maven module. I suggest you do the latter one single time, manually,
and create a proper Maven module. I also suggest you do the former
automatically with Maven and standard Maven dependency resolution once
the previous step is complete.

If you want to continue to do things against The Maven Way, then you
should fall back to the maven-antrun-plugin method which has already
been described. I think this would be quite an error, but, alas,
you're free to do whatever you want..

> Please let me know what you think. Thanks,

Perhaps someone else can step in and explain, I don't think I be
clearer than I have been..

-Jesse

-- 
There are 10 types of people in this world, those
that can read binary and those that can not.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: downloading JavaScript libraries

Posted by Jacob Beard <jb...@cs.mcgill.ca>.
Hi Jesse,

I'm new to Maven, and so I don't completely understand your answer. Why 
would it be desirable to create a module for each JavaScript library in 
this context, especially as this will not facilitate their automated 
downloading?

Also, it still seems like it would be desirable to instruct maven to 
automatically download these libraries, so that they will not need to be 
downloaded manually. Is there no way to instruct Maven to do this?

Please let me know what you think. Thanks,

Jake

On 10-08-25 10:53 PM, Jesse Farinacci wrote:
> I don't think you're on the right track, frankly. It would be better
> for you to create a module for each of your javascript library
> dependencies, and simply manually download it and put it into
> src/main/script (or perhaps src/main/resources to allow the easiest
> packaging). Set the version number to be whatever version of the
> library you're packaging.
>
> Then, in your projects which utilize this javascript, simply depend on
> your module with the appropriate version. This would be more The Maven
> Way. Good luck!
>
> -Jesse
>
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: downloading JavaScript libraries

Posted by Jesse Farinacci <ji...@gmail.com>.
Greetings,

On Wed, Aug 25, 2010 at 10:44 PM, Jacob Beard <jb...@cs.mcgill.ca> wrote:
> My project includes dependencies on several JavaScript libraries, including
> Dojo, RequireJS and beautify-js. I'm currently using Ant's get task to
> download these dependencies, but I'd like to integrate this with my Maven
> build. The way I thought I would do this would be to bind an antrun goal to
> the phase in which dependencies are downloaded. However, after consulting
> the lifecycle reference
> <http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference>,
> I cannot find a Maven phase in which dependencies are downloaded.

Maven dependencies are downloaded in every phase, and only just before
they are required to enter that phase.

> Please let me know if I'm on the right track, or if there is a better way of
> going about this. Thanks,

I don't think you're on the right track, frankly. It would be better
for you to create a module for each of your javascript library
dependencies, and simply manually download it and put it into
src/main/script (or perhaps src/main/resources to allow the easiest
packaging). Set the version number to be whatever version of the
library you're packaging.

Then, in your projects which utilize this javascript, simply depend on
your module with the appropriate version. This would be more The Maven
Way. Good luck!

-Jesse

-- 
There are 10 types of people in this world, those
that can read binary and those that can not.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org