{
TargetDescription target = generateTarget(deploymentMethod);
ProtocolDescription protocol = generateProtocol(deploymentMethod);
Deployment deploymentAnnotation = deploymentMethod.getAnnotation(Deployment.class);
DeploymentDescription description = null;
if (Archive.class.isAssignableFrom(deploymentMethod.getReturnType()))
{
Archive<?> archive = invoke(Archive.class, deploymentMethod);
if (archive instanceof RepositoryForgeArchive)
{
if (Annotations.isAnnotationPresent(deploymentMethod, DeployToRepository.class))
((RepositoryForgeArchive) archive).setAddonRepository(Annotations.getAnnotation(deploymentMethod,
DeployToRepository.class).value());
}
description = new DeploymentDescription(deploymentAnnotation.name(), archive);
description.shouldBeTestable(deploymentAnnotation.testable());
}
else if (Descriptor.class.isAssignableFrom(deploymentMethod.getReturnType()))
{
description = new DeploymentDescription(deploymentAnnotation.name(),
invoke(Descriptor.class, deploymentMethod));
}
description.shouldBeManaged(deploymentAnnotation.managed());
description.setOrder(deploymentAnnotation.order());
if (target != null)
{
description.setTarget(target);
}
if (protocol != null)
{
description.setProtocol(protocol);
}
if (deploymentMethod.isAnnotationPresent(ShouldThrowException.class))
{
description.setExpectedException(deploymentMethod.getAnnotation(ShouldThrowException.class).value());
}
return description;
}