Artifacts.java

package org.docascode.ant.types;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.DataType;
import org.docascode.api.core.errors.DocAsCodeException;

import java.util.ArrayList;
import java.util.List;

public class Artifacts extends DataType {
    private List<Artifact> artifactList = new ArrayList<>();
    public void add(Artifact artifact){
        artifactList.add(artifact);
    }

    public List<org.eclipse.aether.artifact.Artifact> toArtifacts(){
        List<org.eclipse.aether.artifact.Artifact> result =
                new ArrayList<>();
        for (Artifact artifact : artifactList){
            try {
                result.add(artifact.toArtifact());
            } catch (DocAsCodeException e) {
                throw new BuildException(e);
            }
        }
        return result;
    }
}