class DefaultTargetPlatformConfigurationReader {

    protected void addTargetArtifact(TargetPlatformConfiguration result, MavenSession session, MavenProject project,
            Xpp3Dom artifactDom) throws MojoExecutionException {
        Xpp3Dom groupIdDom = artifactDom.getChild("groupId");
        Xpp3Dom artifactIdDom = artifactDom.getChild("artifactId");
        Xpp3Dom versionDom = artifactDom.getChild("version");
        if (groupIdDom == null || artifactIdDom == null || versionDom == null) {
            throw new BuildFailureException(
                    "The target artifact configuration is invalid - <groupId>, <artifactId> and <version> are mandatory");
        }
        Xpp3Dom classifierDom = artifactDom.getChild("classifier");

        String groupId = groupIdDom.getValue();
        String artifactId = artifactIdDom.getValue();
        String version = versionDom.getValue();
        String classifier = classifierDom != null ? classifierDom.getValue() : null;

        //check if target is part of reactor-build
        for (MavenProject otherProject : session.getProjects()) {
            if (groupId.equals(otherProject.getGroupId()) && artifactId.equals(otherProject.getArtifactId())
                    && version.equals(otherProject.getVersion())) {
                if (classifier == null) {
                    File[] targetFiles = listTargetFiles(otherProject.getBasedir());
                    for (File targetFile : targetFiles) {
                        if (isPrimaryTarget(otherProject, targetFile, targetFiles)) {
                            result.addTarget(targetFile);
                            return;
                        }
                    }
                    throwNoPrimaryTargetFound(otherProject, targetFiles);
                } else {
                    File target = new File(otherProject.getBasedir(), classifier + FILE_EXTENSION);
                    if (isTargetFile(target)) {
                        result.addTarget(target);
                        return;
                    } else {
                        throw new MojoExecutionException("target definition file '" + target
                                + "' not found in project '" + project.getName() + "'.");
                    }
                }
            }
        }
        // resolve using maven

        Artifact artifact = repositorySystem.createArtifactWithClassifier(groupId, artifactId, version, TARGET,
                classifier);
        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
        request.setArtifact(artifact);
        request.setLocalRepository(session.getLocalRepository());
        request.setRemoteRepositories(project.getRemoteArtifactRepositories());
        repositorySystem.resolve(request);

        if (artifact.isResolved()) {
            result.addTarget(artifact.getFile());
            return;
        }
        throw new RuntimeException("Could not resolve target platform specification artifact " + artifact);

    }

}