JQuery Availability on Maven Repositories

白昼怎懂夜的黑 提交于 2019-12-03 09:29:55

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).

If your question is about repository of javascript, you can have a look at CDNs:

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.

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>

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!