The dependency plugin can do that, but assembly can also. If you are
doing that to get it into an assembly, you'd be better off just letting
assembly do it for you. Dependency was intended for use cases that
needed the dependencies to be copied or unpacked but not assembled.
(like combining a jar/war into your artifact for install or deploy) 

-----Original Message-----
From: Man-Chi Leung [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 05, 2006 11:52 PM
To: Maven Users List
Subject: Re: [m2] how to change maven-jar-plugin's basedir ?

hi Brett,

I believe this issue is more important than just a path configuration.

the reason I want to change this location is very relevant  to package
and assemble goal

1)  $mvn package
firstly I  copied all my dependencies to target/lib/  during my package
goal

                <!-- PLUGIN: dependency -->
                <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>dependency-maven-plugin</artifactId>
                        <executions>
                                <execution>
                                        <id>copy-dependencies</id>
                                        <phase>package</phase>
                                        <goals>
        
<goal>copy-dependencies</goal>
                                        </goals>
                                        <configuration>
        
<outputDirectory>${project.build.directory}/lib</outputDirectory>
                                        </configuration>
                                </execution>
                        </executions>
                </plugin>

2) $mvn assembly:assembly
* when I do assembly , i jar up all my classes as my-app-1.0-
SNAPSHOT.jar with a manifest for mainClass.
* I added Classpath=true, otherwise, main class resided  in my-
app-1.0-SNAPSHOT.jar  will NOT able to find its depended lib, EVEN if u
have specified in classpath at "Java -cp"

                <!-- PLUGIN: jar -->
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <configuration>
                                <archive>
                                        <manifest>
        
<addClasspath>true</addClasspath>
        
<mainClass>com.mycompany.SimpleApp</mainClass>
                                        </manifest>
                                </archive>
                        </configuration>
                </plugin>
3) * tar up my generated jar together  with all dependencies at / 
target/lib,   as my-app-1.0-SNAPSHOT-bin.tar.gz
                <!-- PLUGIN: assembly -->
                <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
        
<descriptor>src/main/assembly/bin.xml</descriptor>
                        </configuration>
                </plugin>


when u untar my-app-1.0-SNAPSHOT-bin.tar.gz. u should get this
structure:
/my-app-1.0-SNAPSHOT.jar
        /lib/log4j.jar
        /lib/...external.jar

if u have done this way, u will find out the PROLEM when u execute the
followings:
$java -jar my-app-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError:


Bcos , dependency is at lib .. Not the same directory as my-app-1.0-
SNAPSHOT.jar

After all the long story: therefore I must generate my-app-1.0-
SNAPSHOT.jar  to target/lib in the first place


(in fact, I strongly believe that Maven should do this in a more  
standard & transparent manner!! bcos very often, we need to package  
depended jar with our developed componment, and  very likely, to copy  
to target/lib
but now we need to add , again, so many plugins and configure out the  
setting!  it really spent me a couple of days to iron this out! We  
should avoid doing such complexity in maven  !! )

~manchi

On Jan 6, 2006, at 9:49 AM, Brett Porter wrote:

> It's intentional. It's meant to be the location of the project.
>
> What should go in JIRA is the ability to change the output location.
>
> - Brett
>
> On 1/6/06, Henry Isidro <[EMAIL PROTECTED]> wrote:
>> Henry Isidro wrote:
>>
>>> Man-Chi Leung wrote:
>>>
>>>> how can I change the generated jar location from default
>>>> <project_dir>/target/ to <project_dir>/target/lib?
>>>>
>>>>
>>>>         <plugin>
>>>>             <groupId>org.apache.maven.plugins</groupId>
>>>>             <artifactId>maven-jar-plugin</artifactId>
>>>>             <configuration>
>>>>                 <basedir>/target/lib</basedir>   <-------- I  
>>>> want to
>>>> do something  like this. but ERROR!
>>>>                 <archive>
>>>>                     <manifest>
>>>>                         <addClasspath>true</addClasspath>
>>>>
>>>> <mainClass>com.ever.beetles.SimpleJxtaApp</mainClass>
>>>>                     </manifest>
>>>>                 </archive>
>>>>             </configuration>
>>>>         </plugin>
>>>>
>>>> [INFO]
>>>> -------------------------------------------------------------------

>>>> -----
>>>> ----
>>>> [ERROR] BUILD ERROR
>>>> [INFO]
>>>> -------------------------------------------------------------------

>>>> -----
>>>> ----
>>>> [INFO] Error configuring: org.apache.maven.plugins:maven-jar- 
>>>> plugin.
>>>> Reason: ERROR: Cannot override read-only parameter: basedir in  
>>>> goal:
>>>> jar:jar
>>>> [INFO]
>>>> -------------------------------------------------------------------

>>>> -----
>>>> ----
>>>>
>>>>
>>>> -------------------------------------------------------------------

>>>> --
>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>> I looked at the jar plugin source and as expected, basedir is
>>> readonly. I don't think you can change it via this way unless you  
>>> edit
>>> the jar plugin source.
>>>
>>> Regards,
>>> Henry
>>>
>>> --------------------------------------------------------------------

>>> -
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>> I tried removing the readonly setting from the basedir property  
>> from the
>> jar plugin source and I was able to change the basedir property using
>> your configuration. I don't know why the basedir property is  
>> readonly.
>> Maybe you should file a JIRA issue regarding this.
>>
>> Regards,
>> henry
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to