maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Uwe Barthel <bart...@x-reizend.de>
Subject Re: Why isn't maven-dependency-plugin copying my artifacts anymore?
Date Fri, 11 Mar 2016 04:58:31 GMT
Hi David,

I use your pom.xml (but removed parent and org.opendaylight dependencies) and it works well
with:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.3", arch: "x86_64", family: “mac"

$ ls -1 libs/
antlr4-runtime-4.0.jar
mapdb-1.0.4.jar

-- 
barthel@x-reizend.de


> On 11 Mar 2016, at 01:03, David M. Karr <davidmichaelkarr@gmail.com> wrote:
> 
> On 03/10/2016 03:54 PM, Mark Eggers wrote:
>> David,
>> 
>> I just upgraded to 3.3.9, and ran the following on one of my projects
>> (twice):
>> 
>> mvn clean package
>> 
>> In both cases the JAR files were copied to my output directory and
>> included in both the zip and tar.gz files.
>> 
>> I guess a little more information is needed??
> 
> Ok.  Following this is the entire pom.xml file in question.  Two of the artifacts aren't
on MavenCentral, but the example could easily be simplified to not specify those.
> 
> ------------------------------
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
>  <modelVersion>4.0.0</modelVersion>
> 
>  <parent>
>    <groupId>com.cisco.yangide</groupId>
>    <artifactId>com.cisco.yangide.parent</artifactId>
>    <version>1.1.1-SNAPSHOT</version>
>    <relativePath>../..</relativePath>
>  </parent>
> 
>  <artifactId>com.cisco.yangide.core</artifactId>
>  <packaging>eclipse-plugin</packaging>
>  <version>1.1.1-SNAPSHOT</version>
>  <build>
>    <sourceDirectory>src</sourceDirectory>
>    <plugins>
>        <plugin>
>            <groupId>org.apache.maven.plugins</groupId>
>            <artifactId>maven-clean-plugin</artifactId>
>            <configuration>
>                <filesets>
>                    <fileset>
>                        <directory>libs</directory>
>                    </fileset>
>                </filesets>
>            </configuration>
>        </plugin>
>        <plugin>
>            <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-dependency-plugin</artifactId>
>            <version>2.10</version>
>            <executions>
>                <execution>
>                    <id>copy</id>
>                    <phase>prepare-package</phase>
>                    <goals>
>                        <goal>copy</goal>
>                    </goals>
>                    <configuration>
> <outputDirectory>libs</outputDirectory>
>                        <artifactItems>
>                            <artifactItem>
> <groupId>org.antlr</groupId>
> <artifactId>antlr4-runtime</artifactId>
>                                <version>4.0</version>
>                                <type>jar</type>
> <overWrite>true</overWrite>
> <destFileName>antlr4-runtime-4.0.jar</destFileName>
>                            </artifactItem>
>                            <artifactItem>
> <groupId>org.mapdb</groupId>
> <artifactId>mapdb</artifactId>
>                                <version>1.0.4</version>
>                                <type>jar</type>
> <overWrite>true</overWrite>
> <destFileName>mapdb-1.0.4.jar</destFileName>
>                            </artifactItem>
>                            <artifactItem>
> <groupId>org.opendaylight.yangtools</groupId>
> <artifactId>yang-model-api</artifactId>
>                                <version>0.6.1</version>
>                                <type>jar</type>
> <overWrite>true</overWrite>
> <destFileName>yang-model-api-0.6.1.jar</destFileName>
>                            </artifactItem>
>                            <artifactItem>
> <groupId>org.opendaylight.yangtools</groupId>
> <artifactId>yang-parser-impl</artifactId>
>                                <version>0.6.1</version>
>                                <type>jar</type>
> <overWrite>true</overWrite>
> <destFileName>yang-parser-impl-0.6.1.jar</destFileName>
>                            </artifactItem>
>                        </artifactItems>
>                    </configuration>
>                </execution>
>            </executions>
>        </plugin>
>    </plugins>
>  </build>
> </project>
> ----------------------
>> 
>> . . . just my two cents
>> /mde/
>> 
>> On 3/10/2016 3:44 PM, David M. Karr wrote:
>>> On 03/10/2016 03:36 PM, Mark Eggers wrote:
>>>> David,
>>>> 
>>>> If you're providing a list of dependencies, then yes you'll use the copy
>>>> instead of copy-dependencies.
>>>> 
>>>> See the following for that information:
>>>> 
>>>> https://maven.apache.org/plugins/maven-dependency-plugin/index.html
>>>> 
>>>> Also, I notice that you don't have outputDirectory specified. If you
>>>> don't, the dependencies will be copied to
>>>> ${project.build.directory}/dependency.
>>> Actually, I was specifying that individually on each artifactItem, but
>>> it's definitely an improvement to only specify that once.  In any case,
>>> it still makes no difference.  It's not writing the artifacts, whether I
>>> use "copy" or "copy-dependencies", or whether I say to write them to
>>> "libs" or "${project.build.directory}/libs". It ("copy", to be specific)
>>> did it the first time I ran this, but never since then.
>>> 
>>> I'm using Maven 3.3.9, with JDK 1.8.0_60.
>>> 
>>>> See the following for that information:
>>>> 
>>>> https://maven.apache.org/plugins/maven-dependency-plugin/copy-mojo.html
>>>> 
>>>> . . . just my two cents
>>>> /mde/
>>>> 
>>>> On 3/10/2016 3:22 PM, David M. Karr wrote:
>>>>> Thanks, but replacing my "manual" copy goal with "copy-dependencies"
and
>>>>> implicit dependency declarations made no difference.  No error at this
>>>>> phase, it just doesn't do anything.
>>>>> 
>>>>> On 03/10/2016 02:57 PM, Mark Eggers wrote:
>>>>>> David,
>>>>>> 
>>>>>> On 3/10/2016 2:31 PM, David M. Karr wrote:
>>>>>>> Several days ago, on the advice of someone on another list, I
>>>>>>> configured
>>>>>>> the use of the "maven-dependency-plugin" in my POM so that the
build
>>>>>>> would copy some dependencies into a local folder, not inside
the
>>>>>>> target
>>>>>>> folder.
>>>>>>> 
>>>>>>> This worked the very first time I ran the build with it, and
I've been
>>>>>>> using the results for a while.
>>>>>>> 
>>>>>>> Today I started to look at this again, to ensure that these copied
>>>>>>> artifacts would be properly cleaned up from "mvn clean".  I first
>>>>>>> tried
>>>>>>> reconfiguring where it wrote the jars, changing it from "libs"
to
>>>>>>> "target/libs".  For some reason, when I ran the build, it didn't
>>>>>>> create
>>>>>>> "target/libs", nor did it copy the jars.  At that point, I thought
>>>>>>> there
>>>>>>> was some issue with writing them into a subfolder of "target".
>>>>>>> 
>>>>>>> I then changed it back to "libs", but I implemented additional
>>>>>>> "maven-clean-plugin" configuration to make it delete that folder.
>>>>>>> When I
>>>>>>> ran "mvn clean", it did what I expected, removing that folder,
along
>>>>>>> with "target".
>>>>>>> 
>>>>>>> However, when I then tried to build the whole thing again, I
found
>>>>>>> that
>>>>>>> it wasn't creating the "libs" folder, and it wasn't copying the
jars
>>>>>>> there.  I then tried manually creating "libs", but that didn't
>>>>>>> help.  I
>>>>>>> tried adding "--debug", which didn't tell me anything useful.
 I
>>>>>>> imagine
>>>>>>> the same thing that is making it not copy the jars into "libs"
is the
>>>>>>> same thing that prevented it writing them into "target/libs",
so there
>>>>>>> likely wasn't a real issue with using a subfolder of "target",
but
>>>>>>> something else is just preventing it from copying the jars.
>>>>>>> 
>>>>>>> This is what I have in the POM for this plugin (eliding the details
of
>>>>>>> each artifact):
>>>>>>> -----------------
>>>>>>>           <plugin>
>>>>>>> <groupId>org.apache.maven.plugins</groupId>
>>>>>>> <artifactId>maven-dependency-plugin</artifactId>
>>>>>>>               <version>2.10</version>
>>>>>>>               <executions>
>>>>>>>                   <execution>
>>>>>>>                       <id>copy</id>
>>>>>>>                       <phase>package</phase>
>>>>>>>                       <goals>
>>>>>>>                           <goal>copy</goal>
>>>>>>>                       </goals>
>>>>>>>                       <configuration>
>>>>>>>                           <artifactItems>
>>>>>>>                               <artifactItem>
>>>>>>>                               ...
>>>>>>>                               </artifactItem>
>>>>>>>                               <artifactItem>
>>>>>>>                               ...
>>>>>>>                               </artifactItem>
>>>>>>>                               <artifactItem>
>>>>>>>                               ...
>>>>>>>                               </artifactItem>
>>>>>>>                               <artifactItem>
>>>>>>>                               ...
>>>>>>>                               </artifactItem>
>>>>>>>                           </artifactItems>
>>>>>>>                       </configuration>
>>>>>>>                   </execution>
>>>>>>>               </executions>
>>>>>>>           </plugin>
>>>>>>> -------------------
>>>>>> My copy looks like this:
>>>>>> 
>>>>>> <plugin>
>>>>>>    <groupId>org.apache.maven.plugins</groupId>
>>>>>>    <artifactId>maven-dependency-plugin</artifactId>
>>>>>>    <version>2.10</version>
>>>>>>    <executions>
>>>>>>     <execution>
>>>>>>      <phase>prepare-package</phase>
>>>>>>      <goals>
>>>>>>       <goal>copy-dependencies</goal>
>>>>>>      </goals>
>>>>>>      <configuration>
>>>>>>       <outputDirectory>${project.build.directory}/lib</outputDirectory>
>>>>>>       <includeScope>compile</includeScope>
>>>>>>      </configuration>
>>>>>>     </execution>
>>>>>>    </executions>
>>>>>> </plugin>
>>>>>> 
>>>>>> I'm currently running 3.3.3 and JDK 1.8.0_74. I need to upgrade my
>>>>>> Maven.
>>>>>> 
>>>>>> This works as expected, with dependencies getting copied to target/lib.
>>>>>> 
>>>>>> I have this in my JAR plugin:
>>>>>> 
>>>>>> <addClasspath>true</addClasspath>
>>>>>> <classpathPrefix>lib/</classpathPrefix>
>>>>>> 
>>>>>> along with specifying the main class.
>>>>>> 
>>>>>> I create both a zip and a tar.gz file with the assembly plugin.
>>>>>> 
>>>>>> An end user just unpacks the archive, changes to the directory where
>>>>>> the
>>>>>> archive was unpacked, and runs java -jar ${artifactId}.jar.
>>>>>> 
>>>>>> Seems to work reasonably well.
>>>>>> 
>>>>>> . . . just my two cents
>>>>>> /mde/
>> 
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message