// Create contribution model
Contribution contribution = contributionFactory.createContribution();
contribution.setURI(contributionURI.toString());
contribution.setLocation(contributionURL.toString());
ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
contribution.setModelResolver(modelResolver);
contribution.setUnresolved(true);
// Create a contribution scanner
ContributionScanner scanner;
if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
scanner = new DirectoryContributionScanner();
} else {
scanner = new JarContributionScanner();
}
// Scan the contribution and list the artifacts contained in it
List<Artifact> artifacts = contribution.getArtifacts();
boolean contributionMetadata = false;
List<String> artifactURIs = scanner.getArtifacts(contributionURL);
for (String artifactURI: artifactURIs) {
URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);
// Add the deployed artifact model to the contribution
Artifact artifact = this.contributionFactory.createArtifact();
artifact.setURI(artifactURI);
artifact.setLocation(artifactURL.toString());
artifacts.add(artifact);
modelResolver.addModel(artifact);
// Read each artifact
Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
if (model != null) {
artifact.setModel(model);
// Add the loaded model to the model resolver
modelResolver.addModel(model);
// Merge contribution metadata into the contribution model
if (model instanceof ContributionMetadata) {
contributionMetadata = true;
ContributionMetadata c = (ContributionMetadata)model;