'How to publish a test source folder using ivy?

In my project I have two separate source folders - /src where the code is and /test for mock and test objects.

On top of the standard jar (from /src) that ivy successfully publishes for my project I would like to publish another artifact through ivy that only includes the objects in the /test folder in order to be able to share these mock objects with other projects.

Can someone please provide an ivy configuration to support this?

ivy


Solution 1:[1]

1- You need to build a test-jar from the test-folder, lets call it project-test.jar

<javac destdir="build/test" srcdir="test/">
      <classpath refid="test.classpath" />
    </javac> 
<jar destfile="dist/project-test.jar" 
        basedir="build/test"/>

2- Define an artifact in your ivy.xml

 <publications>
    <artifact name="project" type="jar"  conf="default" ext="jar"/>
    <artifact name="project-test" type="jar" conf="test  ext="jar"/>
 </publications>

3- Publish

    <ivy:resolve
        revision="${project.version}"
        conf="compile,test"
    />
    <!-- Alle Artifacts für compile mit dem jars resolver publishen -->
    <ivy:publish 
        revision="${project.version}">  
        <artifacts pattern="dist/[artifact]-[revision].[type]" />
    </ivy:publish>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Viktor Nordling