You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stephan Niedermeier <st...@gmx.de> on 2008/11/29 17:28:58 UTC

How to place the project classpath into a ressource file?

Hi,

I'm using Maven2 to build and assemble my project under Win XP.

The project contains a Java launcher. This launcher needs to know all 
jars in the project. This will be done using a configuration file 
(launcher.properties) and the property "app.classpath". The hard coded 
entry for the property could look like this for example:

app.classpath=lib/commons-logging.jar;lib/commons-httpclient.jar

This works perfectly. But instead of hard coding and maintaining the 
classpath in the configuration file as seen above, I would prefer using 
some sort of Maven 2 Filter which calculates the classpath string 
automatically and then places this string into my configuration file on 
the predefined position. For example similar to this:

app.classpath=${someVarHoldingTheGeneratedClasspathString}

Im wondering whether there is a solution for this in Maven? I couldn't 
find any hint in the Maven2 Filter docs, because there is no such 
variable I could use. Maybe I have overseen something?

Any ideas how I can retrieve the classpath string and place it into my 
configuration file?

PS: Putting the classpath into the META-INF using the <manifest/> tag is 
not an option for me, because its not supported by the Launcher.

Thanks in advance.

Best regards
Stephan



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


Re: How to place the project classpath into a ressource file?

Posted by Brian Fox <br...@reply.infinity.nu>.
I don't think so but it should be easy to patch

--Brian (mobile)


On Nov 29, 2008, at 1:39 PM, Stephan Niedermeier <stephanisworking@gmx.de 
 > wrote:

> Hi Brian,
>
> thanks for the hint, but it seems that the build-classpath goal  
> calculates the full path to the jars (e.g. C:/project/lib/ 
> myJar.jar). Is there a way to make this path relatively to, let's  
> say "lib/" of the assembled folder?
>
> Thanks a lot.
>
> Regards
> Stephan
>
> Brian Fox schrieb:
>> You can use the maven-dependency-plugin:build-classpath goal
>>
>> --Brian (mobile)
>>
>>
>> On Nov 29, 2008, at 11:28 AM, "Stephan Niedermeier" <stephanisworking@gmx.de 
>> > wrote:
>>
>>> Hi,
>>>
>>> I'm using Maven2 to build and assemble my project under Win XP.
>>>
>>> The project contains a Java launcher. This launcher needs to know  
>>> all
>>> jars in the project. This will be done using a configuration file
>>> (launcher.properties) and the property "app.classpath". The hard  
>>> coded
>>> entry for the property could look like this for example:
>>>
>>> app.classpath=lib/commons-logging.jar;lib/commons-httpclient.jar
>>>
>>> This works perfectly. But instead of hard coding and maintaining the
>>> classpath in the configuration file as seen above, I would prefer  
>>> using
>>> some sort of Maven 2 Filter which calculates the classpath string
>>> automatically and then places this string into my configuration  
>>> file on
>>> the predefined position. For example similar to this:
>>>
>>> app.classpath=${someVarHoldingTheGeneratedClasspathString}
>>>
>>> Im wondering whether there is a solution for this in Maven? I  
>>> couldn't
>>> find any hint in the Maven2 Filter docs, because there is no such
>>> variable I could use. Maybe I have overseen something?
>>>
>>> Any ideas how I can retrieve the classpath string and place it  
>>> into my
>>> configuration file?
>>>
>>> PS: Putting the classpath into the META-INF using the <manifest/>  
>>> tag is
>>> not an option for me, because its not supported by the Launcher.
>>>
>>> Thanks in advance.
>>>
>>> Best regards
>>> Stephan
>>>
>>>
>>>
>>> --- 
>>> ------------------------------------------------------------------
>>> 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
>

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


Re: How to place the project classpath into a ressource file?

Posted by Brian Fox <br...@reply.infinity.nu>.
Heh... I Forgot about that

--Brian (mobile)


On Nov 29, 2008, at 2:06 PM, Stephan Niedermeier <stephanisworking@gmx.de 
 > wrote:

> Hi,
>
> got it. Thanks. For those interested in:
>
> Use the "prefix" together with the "outputFilterFile" parameter of  
> the build-classpath goal. Example:
>
>           <plugin>
>               <groupId>org.apache.maven.plugins</groupId>
>               <artifactId>maven-dependency-plugin</artifactId>
>               <configuration>
>                   <outputFilterFile>true</outputFilterFile>
>                   <prefix>lib</prefix>
>               </configuration>
>           </plugin>
>
> Regards
> Stephan
>
> Stephan Niedermeier schrieb:
>> Hi Brian,
>>
>> thanks for the hint, but it seems that the build-classpath goal  
>> calculates the full path to the jars (e.g. C:/project/lib/ 
>> myJar.jar). Is there a way to make this path relatively to, let's  
>> say "lib/" of the assembled folder?
>>
>> Thanks a lot.
>>
>> Regards
>> Stephan
>>
>> Brian Fox schrieb:
>>> You can use the maven-dependency-plugin:build-classpath goal
>>>
>>> --Brian (mobile)
>>>
>>>
>>> On Nov 29, 2008, at 11:28 AM, "Stephan Niedermeier" <stephanisworking@gmx.de 
>>> > wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm using Maven2 to build and assemble my project under Win XP.
>>>>
>>>> The project contains a Java launcher. This launcher needs to know  
>>>> all
>>>> jars in the project. This will be done using a configuration file
>>>> (launcher.properties) and the property "app.classpath". The hard  
>>>> coded
>>>> entry for the property could look like this for example:
>>>>
>>>> app.classpath=lib/commons-logging.jar;lib/commons-httpclient.jar
>>>>
>>>> This works perfectly. But instead of hard coding and maintaining  
>>>> the
>>>> classpath in the configuration file as seen above, I would prefer  
>>>> using
>>>> some sort of Maven 2 Filter which calculates the classpath string
>>>> automatically and then places this string into my configuration  
>>>> file on
>>>> the predefined position. For example similar to this:
>>>>
>>>> app.classpath=${someVarHoldingTheGeneratedClasspathString}
>>>>
>>>> Im wondering whether there is a solution for this in Maven? I  
>>>> couldn't
>>>> find any hint in the Maven2 Filter docs, because there is no such
>>>> variable I could use. Maybe I have overseen something?
>>>>
>>>> Any ideas how I can retrieve the classpath string and place it  
>>>> into my
>>>> configuration file?
>>>>
>>>> PS: Putting the classpath into the META-INF using the <manifest/>  
>>>> tag is
>>>> not an option for me, because its not supported by the Launcher.
>>>>
>>>> Thanks in advance.
>>>>
>>>> Best regards
>>>> Stephan
>>>>
>>>>
>>>>
>>>> --- 
>>>> ------------------------------------------------------------------
>>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: How to place the project classpath into a ressource file?

Posted by Stephan Niedermeier <st...@gmx.de>.
Hi,

got it. Thanks. For those interested in:

Use the "prefix" together with the "outputFilterFile" parameter of the 
build-classpath goal. Example:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <configuration>
                    <outputFilterFile>true</outputFilterFile>
                    <prefix>lib</prefix>
                </configuration>
            </plugin>

Regards
Stephan

Stephan Niedermeier schrieb:
> Hi Brian,
>
> thanks for the hint, but it seems that the build-classpath goal 
> calculates the full path to the jars (e.g. C:/project/lib/myJar.jar). 
> Is there a way to make this path relatively to, let's say "lib/" of 
> the assembled folder?
>
> Thanks a lot.
>
> Regards
> Stephan
>
> Brian Fox schrieb:
>> You can use the maven-dependency-plugin:build-classpath goal
>>
>> --Brian (mobile)
>>
>>
>> On Nov 29, 2008, at 11:28 AM, "Stephan Niedermeier" 
>> <st...@gmx.de> wrote:
>>
>>> Hi,
>>>
>>> I'm using Maven2 to build and assemble my project under Win XP.
>>>
>>> The project contains a Java launcher. This launcher needs to know all
>>> jars in the project. This will be done using a configuration file
>>> (launcher.properties) and the property "app.classpath". The hard coded
>>> entry for the property could look like this for example:
>>>
>>> app.classpath=lib/commons-logging.jar;lib/commons-httpclient.jar
>>>
>>> This works perfectly. But instead of hard coding and maintaining the
>>> classpath in the configuration file as seen above, I would prefer using
>>> some sort of Maven 2 Filter which calculates the classpath string
>>> automatically and then places this string into my configuration file on
>>> the predefined position. For example similar to this:
>>>
>>> app.classpath=${someVarHoldingTheGeneratedClasspathString}
>>>
>>> Im wondering whether there is a solution for this in Maven? I couldn't
>>> find any hint in the Maven2 Filter docs, because there is no such
>>> variable I could use. Maybe I have overseen something?
>>>
>>> Any ideas how I can retrieve the classpath string and place it into my
>>> configuration file?
>>>
>>> PS: Putting the classpath into the META-INF using the <manifest/> 
>>> tag is
>>> not an option for me, because its not supported by the Launcher.
>>>
>>> Thanks in advance.
>>>
>>> Best regards
>>> Stephan
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>


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


Re: How to place the project classpath into a ressource file?

Posted by Stephan Niedermeier <st...@gmx.de>.
Hi Brian,

thanks for the hint, but it seems that the build-classpath goal 
calculates the full path to the jars (e.g. C:/project/lib/myJar.jar). Is 
there a way to make this path relatively to, let's say "lib/" of the 
assembled folder?

Thanks a lot.

Regards
Stephan

Brian Fox schrieb:
> You can use the maven-dependency-plugin:build-classpath goal
>
> --Brian (mobile)
>
>
> On Nov 29, 2008, at 11:28 AM, "Stephan Niedermeier" 
> <st...@gmx.de> wrote:
>
>> Hi,
>>
>> I'm using Maven2 to build and assemble my project under Win XP.
>>
>> The project contains a Java launcher. This launcher needs to know all
>> jars in the project. This will be done using a configuration file
>> (launcher.properties) and the property "app.classpath". The hard coded
>> entry for the property could look like this for example:
>>
>> app.classpath=lib/commons-logging.jar;lib/commons-httpclient.jar
>>
>> This works perfectly. But instead of hard coding and maintaining the
>> classpath in the configuration file as seen above, I would prefer using
>> some sort of Maven 2 Filter which calculates the classpath string
>> automatically and then places this string into my configuration file on
>> the predefined position. For example similar to this:
>>
>> app.classpath=${someVarHoldingTheGeneratedClasspathString}
>>
>> Im wondering whether there is a solution for this in Maven? I couldn't
>> find any hint in the Maven2 Filter docs, because there is no such
>> variable I could use. Maybe I have overseen something?
>>
>> Any ideas how I can retrieve the classpath string and place it into my
>> configuration file?
>>
>> PS: Putting the classpath into the META-INF using the <manifest/> tag is
>> not an option for me, because its not supported by the Launcher.
>>
>> Thanks in advance.
>>
>> Best regards
>> Stephan
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: How to place the project classpath into a ressource file?

Posted by Brian Fox <br...@reply.infinity.nu>.
You can use the maven-dependency-plugin:build-classpath goal

--Brian (mobile)


On Nov 29, 2008, at 11:28 AM, "Stephan Niedermeier" <stephanisworking@gmx.de 
 > wrote:

> Hi,
>
> I'm using Maven2 to build and assemble my project under Win XP.
>
> The project contains a Java launcher. This launcher needs to know all
> jars in the project. This will be done using a configuration file
> (launcher.properties) and the property "app.classpath". The hard coded
> entry for the property could look like this for example:
>
> app.classpath=lib/commons-logging.jar;lib/commons-httpclient.jar
>
> This works perfectly. But instead of hard coding and maintaining the
> classpath in the configuration file as seen above, I would prefer  
> using
> some sort of Maven 2 Filter which calculates the classpath string
> automatically and then places this string into my configuration file  
> on
> the predefined position. For example similar to this:
>
> app.classpath=${someVarHoldingTheGeneratedClasspathString}
>
> Im wondering whether there is a solution for this in Maven? I couldn't
> find any hint in the Maven2 Filter docs, because there is no such
> variable I could use. Maybe I have overseen something?
>
> Any ideas how I can retrieve the classpath string and place it into my
> configuration file?
>
> PS: Putting the classpath into the META-INF using the <manifest/>  
> tag is
> not an option for me, because its not supported by the Launcher.
>
> Thanks in advance.
>
> Best regards
> Stephan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>