问题
I noticed that there are a few Maven plugins for Eclipse that support JavaScript development. The problem with using these is that I cannot find any JavaScript artifacts in Maven Central Repository. Specifically, I was looking for JQuery.
Is there a dedicated Maven repository for JavaScript?
Thanks
回答1:
Try webjars. http://www.webjars.org/
It has all the major libraries, plus it's in github, so you can fork your own versions if you really need to.
It should work well with a servlet 3 spec container with meta data scanning. But I use https://github.com/bazaarvoice/dropwizard-webjars-resource/ to serve it explicitly, since I'm using JAX-RS (using Jersey).
回答2:
If your question is about repository of javascript, you can have a look at CDNs:
- Google CDN: http://code.google.com/apis/libraries/ (you can just use the src link without using google's javascript)
- Microsoft CDN: http://www.asp.net/ajaxlibrary/cdn.ashx
However, please be mindful that they do not provide a local javascript (like how Maven retrieve and store jars), thus Internet connection is necessary and there will be a network overhead.
And more, they do not manage dependencies of javascript. Dependency management of javascript is a much bigger issue in itself.
Hope I have answered your question.
回答3:
I have been working on and off in my spare time on a better story for Maven and JavaScript development. You can see the results of my efforts at jszip.org
Personally speaking I think there are only a few issues left to resolve:
How to handle LESS and SASS stylesheets in dependencies
Tidy up the code to make it more extensible
Better documentation.
As part of the effort, I do repackage JavaScript libraries as simple .zip
files, you can see a complete list on central and you will note that jQuery is one of them, though I probably have to pick up the 1.9.x releases when I next get a window of opertunity
Because I am packaging these as plain simple .zip
files you don't have to use the rest of the jszip toolchain, though obviously I think it superior to just unpacking the .zip
as part of your build with, e.g. dependency:unpack-dependencies
Here is an example of how to add a jszip module using its tooling:
<project>
...
<dependencies>
...
<dependency>
<groupId>org.jszip.redist</groupId>
<artifactId>jquery</artifactId>
<version>1.8.3</version>
<type>jszip</type>
</dependency>
...
</dependencies>
<build>
...
<plugins>
...
<plugin>
<groupId>org.jszip.maven</groupId>
<artifactId>jszip-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
<!-- this next part assumes you want to minify all javascript for releases
and that your release profile used by the maven release plugin is called
'release' (i.e. the default) -->
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.jszip.maven</groupId>
<artifactId>jszip-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>optimize</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
回答4:
Maven is more popular for java than javascript, so you will only find a limited number of javascript libraries on the maven central repo. JQuery is quite popular though, and several packages for it exist on maven central as you can see here.
For other javascript libraries, you can try to get maven to use npm, which is a popular package management system for Node.js. There is a plugin that will allow you to download npm modules in your maven build. Here is the jquery npm package.
If that fails, you can always package the javascript libraries you need and upload them to maven central repo yourself.
来源:https://stackoverflow.com/questions/8318233/jquery-availability-on-maven-repositories