You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Haszlakiewicz, Eric" <EH...@transunion.com> on 2010/06/15 00:23:15 UTC
using javascript dependencies in a webapp (war packaging)
I've got a webapp that uses javascript files from third party projects.
For instance, one of the files we use is prototype.js. It seems like
this must be something that many people have done in the past, but I
can't seem to find much information about it.
The first issue I have is that I can't seem to find a maven repository
that has this file (or any of the other javascript scripts I use). Is
there one?
Since I couldn't find one, I uploaded a copy to my local repository
(Nexus) using:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.prototypejs</groupId>
<artifactId>prototype</artifactId>
<version>1.6.1</version>
<packaging>js</packaging>
<url>http://prototypejs.org/assets/2009/8/31/prototype.js</url>
</project>
and I then added an entry to the pom for my webapp:
<dependency>
<groupId>org.prototypejs</groupId>
<artifactId>prototype</artifactId>
<type>js</type>
<version>1.6.1</version>
</dependency>
but I can't figure out how to get this to actually get included into the
war file. I tried configuring an overlay, but it doesn't seem to do
anything:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>org.prototypejs</groupId>
<artifactId>prototype</artifactId>
<type>js</type>
<targetPath>common/javascript</targetPath>
</overlay>
</overlays>
</configuration>
</plugin>
All I see is a warning when I run "mvn package":
[WARNING] Skip unpacking dependency
file[/u/ehaszla/.m2/repository/org/prototypejs/prototype/1.6.1/prototype
-1.6.1.js with unknown extension[js]
I want to end up with a file called "prototype-1.6.1.js" in the
"common/javascript" directory within the war file.
How do I get this to work?
eric
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: using javascript dependencies in a webapp (war packaging)
Posted by Shan Syed <sh...@gmail.com>.
I'm considering moving my solution to using the concept of WAR overlays;
a WAR project that requires certain javascripts specifies those as project
dependencies, which themselves are simple WAR projects with only js files in
their correct paths
they get slapped onto the using WARs, and presto, no weirdness with copying
and unzipping directly
On Tue, Jun 15, 2010 at 6:23 PM, Haszlakiewicz, Eric <EHASZLA@transunion.com
> wrote:
> >-----Original Message-----
> >From: Shan Syed [mailto:shan.ss@gmail.com]
> >
> >I've worked on projects that share common javascript files, so I used a
> >simple assembly descriptor to zip each set of files and install them as
> >maven artifacts
> >WAR projects then just specified them as dependencies in their POMs
> >it's nice then to be able to treat these artifacts like any other
> project
> >(versioned, deployable to a repo, etc)
> >I used the maven-dependency plugin to unzip them to a standard folder
> >
> >we didn't require any parsing or compiling of the js, so this worked
> out
> >fine for simple packaging and unzipping
>
> I ended up doing something similar. In case anyone else needs to do
> this in the future the steps I took were:
> 1) Create a jar file containing prototype-1.6.1.js at the top level
> [*1]. I also included a hand written README file in the META-INF
> directory with information about where the js file came from.
> 2) I deployed this to my local nexus repository as
> org.prototypejs:prototype:jar:1.6.1
> 3) I added the dependency to my webapp's pom.xml file with the
> "provided" scope. That scope is needed to prevent the jar file from
> being included in the war. (for some reason using "compile" scope
> didn't omit it)
> 4) I added the overlay configuration to the maven-war-plugin as
> described in my original message. Since the README file is in the
> META-INF directory it doesn't get included.
>
> And now I get the js file extracted from the dependency jar file and
> included in the right place in the war file.
>
> This probably wouldn't work if prototypejs actually provided their own
> artifact, since the js file would probably be in a subdirectory, and
> there's no way to tell maven to rearrange things.
> However, in that case, I think I'd be able to use the maven-dependency
> plugin to unpack it to a temporary location, and then use some inline
> tasks in a maven-antrun-plugin to move the files to the right place.
> I've done this in other projects I've worked on and it's kind of
> annoying that maven doesn't support stuff like this natively, but at
> least it works.
>
> eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
RE: using javascript dependencies in a webapp (war packaging)
Posted by "Haszlakiewicz, Eric" <EH...@transunion.com>.
>-----Original Message-----
>From: Shan Syed [mailto:shan.ss@gmail.com]
>
>I've worked on projects that share common javascript files, so I used a
>simple assembly descriptor to zip each set of files and install them as
>maven artifacts
>WAR projects then just specified them as dependencies in their POMs
>it's nice then to be able to treat these artifacts like any other
project
>(versioned, deployable to a repo, etc)
>I used the maven-dependency plugin to unzip them to a standard folder
>
>we didn't require any parsing or compiling of the js, so this worked
out
>fine for simple packaging and unzipping
I ended up doing something similar. In case anyone else needs to do
this in the future the steps I took were:
1) Create a jar file containing prototype-1.6.1.js at the top level
[*1]. I also included a hand written README file in the META-INF
directory with information about where the js file came from.
2) I deployed this to my local nexus repository as
org.prototypejs:prototype:jar:1.6.1
3) I added the dependency to my webapp's pom.xml file with the
"provided" scope. That scope is needed to prevent the jar file from
being included in the war. (for some reason using "compile" scope
didn't omit it)
4) I added the overlay configuration to the maven-war-plugin as
described in my original message. Since the README file is in the
META-INF directory it doesn't get included.
And now I get the js file extracted from the dependency jar file and
included in the right place in the war file.
This probably wouldn't work if prototypejs actually provided their own
artifact, since the js file would probably be in a subdirectory, and
there's no way to tell maven to rearrange things.
However, in that case, I think I'd be able to use the maven-dependency
plugin to unpack it to a temporary location, and then use some inline
tasks in a maven-antrun-plugin to move the files to the right place.
I've done this in other projects I've worked on and it's kind of
annoying that maven doesn't support stuff like this natively, but at
least it works.
eric
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: using javascript dependencies in a webapp (war packaging)
Posted by Shan Syed <sh...@gmail.com>.
I've worked on projects that share common javascript files, so I used a
simple assembly descriptor to zip each set of files and install them as
maven artifacts
WAR projects then just specified them as dependencies in their POMs
it's nice then to be able to treat these artifacts like any other project
(versioned, deployable to a repo, etc)
I used the maven-dependency plugin to unzip them to a standard folder
we didn't require any parsing or compiling of the js, so this worked out
fine for simple packaging and unzipping
On Mon, Jun 14, 2010 at 6:23 PM, Haszlakiewicz, Eric <EHASZLA@transunion.com
> wrote:
>
> I've got a webapp that uses javascript files from third party projects.
> For instance, one of the files we use is prototype.js. It seems like
> this must be something that many people have done in the past, but I
> can't seem to find much information about it.
>
> The first issue I have is that I can't seem to find a maven repository
> that has this file (or any of the other javascript scripts I use). Is
> there one?
>
> Since I couldn't find one, I uploaded a copy to my local repository
> (Nexus) using:
> <?xml version="1.0" encoding="UTF-8"?>
> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd"
> xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <modelVersion>4.0.0</modelVersion>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <version>1.6.1</version>
> <packaging>js</packaging>
> <url>http://prototypejs.org/assets/2009/8/31/prototype.js</url>
> </project>
>
> and I then added an entry to the pom for my webapp:
> <dependency>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <type>js</type>
> <version>1.6.1</version>
> </dependency>
>
>
> but I can't figure out how to get this to actually get included into the
> war file. I tried configuring an overlay, but it doesn't seem to do
> anything:
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <overlays>
> <overlay>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <type>js</type>
> <targetPath>common/javascript</targetPath>
> </overlay>
> </overlays>
> </configuration>
> </plugin>
>
> All I see is a warning when I run "mvn package":
> [WARNING] Skip unpacking dependency
> file[/u/ehaszla/.m2/repository/org/prototypejs/prototype/1.6.1/prototype
> -1.6.1.js with unknown extension[js]
>
> I want to end up with a file called "prototype-1.6.1.js" in the
> "common/javascript" directory within the war file.
>
> How do I get this to work?
>
> eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
RE: using javascript dependencies in a webapp (war packaging)
Posted by "Haszlakiewicz, Eric" <EH...@transunion.com>.
>From: Manos Batsis [mailto:manos_lists@geekologue.com]
>On 06/15/2010 01:55 AM, Haszlakiewicz, Eric wrote:
>> Yeah, I started to take a look at the maven-javascript-plugin, but it
>> looks very oriented towards *developing* js packages, and I just want
to
>> *use* an existing one.
>>
>> It also isn't clear how to tell it where to actually put the files.
I
>> didn't see anything like that in the mvn-jstools either, and using a
>> filter isn't going to work very well for my project. (At the moment
I
>> just need to get an existing project converted to maven with NO
changes
>> to the code at all)
>
>If you can put a JS lib as a JAR in a WAR lib as-is, the servlet filter
>of jstools will just look it up from the classpath and serve it. Take a
>look in the docos, it might work for you and worth it in actually
>handling JS deps.
Like I said, using a servlet filter isn't going to work. I need to end
up with a war file that is essentially unchanged from the one that I was
building before so I can guarantee to the testing team that everything
will work exactly as before. The only thing I'm trying to change is to
convert from building with ant, to building with maven.
Thanks for the suggestion though. I'll probably take a look at using
that for future projects.
Yet another snag to using the maven-javascript-plugin is that it doesn't
appear to actually be available, at least not on Maven central. Oh
well, I think I figured out a way to do what I need (which I'll explain
in a different message).
eric
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: using javascript dependencies in a webapp (war packaging)
Posted by Manos Batsis <ma...@geekologue.com>.
On 06/15/2010 01:55 AM, Haszlakiewicz, Eric wrote:
>> -----Original Message-----
>> From: Manos Batsis [mailto:manos_lists@geekologue.com]
>>
>> There is no standard convention yet AFAIK. Including the JS libs in the
>> war is one thing, making it accessible to the browser through a
> specific
>> URL is another.
>
> Well that sucks. :(
>
>> Here (at Abiss.gr) we use the JStools plugin [1]; we include JS libs
>> using JARs as everything else and a filter [2] to serve scripts to the
>> client. I think the maven-javascript-plugin [3] has something else.
>>
>> Searching the archives should give more info, although both projects
>> have pretty good documentation. Overall however, JS libs in repos have
>> not cought on - you will have to include libs in your own repo for most
>> stuff.
>>
>> [1] http://dev.abiss.gr/mvn-jstools/
>> [2] http://dev.abiss.gr/mvn-jstools/js-packaging.html
>> [3] http://mojo.codehaus.org/javascript-maven-tools/
>
> Yeah, I started to take a look at the maven-javascript-plugin, but it
> looks very oriented towards *developing* js packages, and I just want to
> *use* an existing one.
>
> It also isn't clear how to tell it where to actually put the files. I
> didn't see anything like that in the mvn-jstools either, and using a
> filter isn't going to work very well for my project. (At the moment I
> just need to get an existing project converted to maven with NO changes
> to the code at all)
If you can put a JS lib as a JAR in a WAR lib as-is, the servlet filter
of jstools will just look it up from the classpath and serve it. Take a
look in the docos, it might work for you and worth it in actually
handling JS deps.
Manos
>
> I'll take a closer look tomorrow and see if there's something I can use.
>
> Thanks,
>
> eric
>
> ---------------------------------------------------------------------
> 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: using javascript dependencies in a webapp (war packaging)
Posted by "Haszlakiewicz, Eric" <EH...@transunion.com>.
>-----Original Message-----
>From: Manos Batsis [mailto:manos_lists@geekologue.com]
>
>There is no standard convention yet AFAIK. Including the JS libs in the
>war is one thing, making it accessible to the browser through a
specific
>URL is another.
Well that sucks. :(
>Here (at Abiss.gr) we use the JStools plugin [1]; we include JS libs
>using JARs as everything else and a filter [2] to serve scripts to the
>client. I think the maven-javascript-plugin [3] has something else.
>
>Searching the archives should give more info, although both projects
>have pretty good documentation. Overall however, JS libs in repos have
>not cought on - you will have to include libs in your own repo for most
>stuff.
>
>[1] http://dev.abiss.gr/mvn-jstools/
>[2] http://dev.abiss.gr/mvn-jstools/js-packaging.html
>[3] http://mojo.codehaus.org/javascript-maven-tools/
Yeah, I started to take a look at the maven-javascript-plugin, but it
looks very oriented towards *developing* js packages, and I just want to
*use* an existing one.
It also isn't clear how to tell it where to actually put the files. I
didn't see anything like that in the mvn-jstools either, and using a
filter isn't going to work very well for my project. (At the moment I
just need to get an existing project converted to maven with NO changes
to the code at all)
I'll take a closer look tomorrow and see if there's something I can use.
Thanks,
eric
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: using javascript dependencies in a webapp (war packaging)
Posted by Manos Batsis <ma...@geekologue.com>.
On 06/15/2010 01:23 AM, Haszlakiewicz, Eric wrote:
>
> I've got a webapp that uses javascript files from third party projects.
> For instance, one of the files we use is prototype.js. It seems like
> this must be something that many people have done in the past, but I
> can't seem to find much information about it.
>
> The first issue I have is that I can't seem to find a maven repository
> that has this file (or any of the other javascript scripts I use). Is
> there one?
>
> Since I couldn't find one, I uploaded a copy to my local repository
> (Nexus) using:
> <?xml version="1.0" encoding="UTF-8"?>
> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd"
> xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <modelVersion>4.0.0</modelVersion>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <version>1.6.1</version>
> <packaging>js</packaging>
> <url>http://prototypejs.org/assets/2009/8/31/prototype.js</url>
> </project>
>
> and I then added an entry to the pom for my webapp:
> <dependency>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <type>js</type>
> <version>1.6.1</version>
> </dependency>
>
>
> but I can't figure out how to get this to actually get included into the
> war file. I tried configuring an overlay, but it doesn't seem to do
> anything:
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <overlays>
> <overlay>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <type>js</type>
> <targetPath>common/javascript</targetPath>
> </overlay>
> </overlays>
> </configuration>
> </plugin>
>
> All I see is a warning when I run "mvn package":
> [WARNING] Skip unpacking dependency
> file[/u/ehaszla/.m2/repository/org/prototypejs/prototype/1.6.1/prototype
> -1.6.1.js with unknown extension[js]
>
> I want to end up with a file called "prototype-1.6.1.js" in the
> "common/javascript" directory within the war file.
>
> How do I get this to work?
There is no standard convention yet AFAIK. Including the JS libs in the
war is one thing, making it accessible to the browser through a specific
URL is another.
Here (at Abiss.gr) we use the JStools plugin [1]; we include JS libs
using JARs as everything else and a filter [2] to serve scripts to the
client. I think the maven-javascript-plugin [3] has something else.
Searching the archives should give more info, although both projects
have pretty good documentation. Overall however, JS libs in repos have
not cought on - you will have to include libs in your own repo for most
stuff.
[1] http://dev.abiss.gr/mvn-jstools/
[2] http://dev.abiss.gr/mvn-jstools/js-packaging.html
[3] http://mojo.codehaus.org/javascript-maven-tools/
hth,
Manos
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: using javascript dependencies in a webapp (war packaging)
Posted by Nick Stolwijk <ni...@gmail.com>.
I don't know the state of the plugin, but have a look at the Maven
Javascript Plugin.
http://mojo.codehaus.org/javascript-maven-tools/javascript-maven-plugin/index.html
Hth,
Nick Stolwijk
~Java Developer~
IPROFS BV.
Claus Sluterweg 125
2012 WS Haarlem
http://www.iprofs.nl
On Tue, Jun 15, 2010 at 12:23 AM, Haszlakiewicz, Eric
<EH...@transunion.com> wrote:
>
> I've got a webapp that uses javascript files from third party projects.
> For instance, one of the files we use is prototype.js. It seems like
> this must be something that many people have done in the past, but I
> can't seem to find much information about it.
>
> The first issue I have is that I can't seem to find a maven repository
> that has this file (or any of the other javascript scripts I use). Is
> there one?
>
> Since I couldn't find one, I uploaded a copy to my local repository
> (Nexus) using:
> <?xml version="1.0" encoding="UTF-8"?>
> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd"
> xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <modelVersion>4.0.0</modelVersion>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <version>1.6.1</version>
> <packaging>js</packaging>
> <url>http://prototypejs.org/assets/2009/8/31/prototype.js</url>
> </project>
>
> and I then added an entry to the pom for my webapp:
> <dependency>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <type>js</type>
> <version>1.6.1</version>
> </dependency>
>
>
> but I can't figure out how to get this to actually get included into the
> war file. I tried configuring an overlay, but it doesn't seem to do
> anything:
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <overlays>
> <overlay>
> <groupId>org.prototypejs</groupId>
> <artifactId>prototype</artifactId>
> <type>js</type>
> <targetPath>common/javascript</targetPath>
> </overlay>
> </overlays>
> </configuration>
> </plugin>
>
> All I see is a warning when I run "mvn package":
> [WARNING] Skip unpacking dependency
> file[/u/ehaszla/.m2/repository/org/prototypejs/prototype/1.6.1/prototype
> -1.6.1.js with unknown extension[js]
>
> I want to end up with a file called "prototype-1.6.1.js" in the
> "common/javascript" directory within the war file.
>
> How do I get this to work?
>
> eric
>
> ---------------------------------------------------------------------
> 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