2

I am copying a resource into another folder before packaging using the maven-dependecy-plugins copy goal.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>copy</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <failBuild>false</failBuild>
                <artifactItems>
                    <artifactItem>
                        <groupId>my.groupID</groupId>
                        <artifactId>myArtifact</artifactId>
                        <version>0.0.1-SNAPSHOT</version>
                        <type>jar</type>
                        <overWrite>true</overWrite>
                        <outputDirectory>my/custom/path</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

The resource is not vital and it is likely possible that it is not accessible. That's why I want the build not to fail if it is not accessible. I already set the failBuild property to false but it had no effect. Is there a way to achieve this?

André Stannek
  • 7,773
  • 31
  • 52

2 Answers2

1

I guess you get a resolve problem, that the artifact doesnt exist or can't be found in any repository. That's how maven works, if you specify a dependency you need to be able to retrieve it.

Peter Svensson
  • 6,105
  • 1
  • 31
  • 31
  • Yes, I knew that. My question is if theres any way around that strict policy. That artifact is not even declared in the dependencies section so I thought it must be possible to skip it in the copy goal if it cannot be resolved. – André Stannek Feb 02 '12 at 18:43
  • 1
    I'm pretty sure that it can't be done using the dependency plugin. I'd use the antrun plugin and the copy target... – Peter Svensson Feb 02 '12 at 18:59
  • OK, i'll give it a try tomorrow. Thanks! – André Stannek Feb 02 '12 at 20:16
  • If tried it today. If I got it right I have to either declare my dependency in the dependencies section (which of course also makes the build fail if it's missing) or have to provide an actual file. Or am I missing something? What I actually need is to load my artifact via groupId and artifactId but ignore it if it cannot be found in the repositories. – André Stannek Feb 04 '12 at 16:12
  • I still don't understand why the artifact doesn't exist? Thats a rather strange behaviour you want to implement :). What is the reason for the artifact not to exist? – Peter Svensson Feb 04 '12 at 19:11
  • The artifact is some kind of plugin. It depends on the primary project but not the other way around. So I can't buid the artifact before my primary project was built at least once. But when I build my package the artifact should be included, so you don't have to copy it manually when deploying. So even if there is no real cycling dependency in the architecture the two builds are dependent. I think it's OK but if you have a "cleaner" solution to achieve this feel free to tell me :-) – André Stannek Feb 04 '12 at 19:47
  • 1
    Hard to tell by the brief description. Do you have a mail address I can reach you on so we can dig deeper :) – Peter Svensson Feb 04 '12 at 20:05
  • I resolved my problem. Posting the answer in a minute. Thanks for all the input :) – André Stannek Feb 05 '12 at 17:05
0

I resolved my problem by using the copy artifact plugin of jenkins now.

André Stannek
  • 7,773
  • 31
  • 52