use of org.gradle.api.InvalidUserDataException in project atlas by alibaba.
the class PublishToMavenRepositoryHook method publish.
@TaskAction
public void publish() {
MavenPublicationInternal publicationInternal = getPublicationInternal();
if (publicationInternal == null) {
throw new InvalidUserDataException("The 'publication' property is required");
}
MavenArtifactRepository repository = getRepository();
if (repository == null) {
throw new InvalidUserDataException("The 'repository' property is required");
}
doPublish(publicationInternal, repository);
}
use of org.gradle.api.InvalidUserDataException in project zaproxy by zaproxy.
the class CreateGitHubRelease method createRelease.
@TaskAction
public void createRelease() throws IOException {
if (bodyFile.isPresent() && body.isPresent()) {
throw new InvalidUserDataException("Only one type of body property must be set.");
}
if (checksumAlgorithm.get().isEmpty()) {
throw new IllegalArgumentException("The checksum algorithm must not be empty.");
}
GitHubUser ghUser = getUser().get();
GHRepository ghRepo = GitHub.connect(ghUser.getName(), ghUser.getAuthToken()).getRepository(repo.get());
validateTagExists(ghRepo, tag.get());
validateReleaseDoesNotExist(ghRepo, tag.get());
StringBuilder releaseBody = new StringBuilder(250);
releaseBody.append(bodyFile.isPresent() ? readContents(bodyFile.getAsFile().get().toPath()) : body.getOrElse(""));
if (addChecksums.get()) {
if (releaseBody.length() != 0) {
releaseBody.append("\n\n---\n");
}
appendChecksumsTable(releaseBody);
}
GHRelease release = ghRepo.createRelease(tag.get()).name(title.get()).body(releaseBody.toString()).prerelease(prerelease.get()).draft(true).create();
for (Asset asset : assets) {
release.uploadAsset(asset.getFile().getAsFile().get(), asset.getContentType().get());
}
if (!draft.get()) {
release.update().draft(false).update();
}
}
use of org.gradle.api.InvalidUserDataException in project spring-boot by spring-projects.
the class UpgradeBom method upgradeDependencies.
@TaskAction
@SuppressWarnings("deprecation")
void upgradeDependencies() {
GitHubRepository repository = createGitHub().getRepository(this.bom.getUpgrade().getGitHub().getOrganization(), this.bom.getUpgrade().getGitHub().getRepository());
List<String> availableLabels = repository.getLabels();
List<String> issueLabels = this.bom.getUpgrade().getGitHub().getIssueLabels();
if (!availableLabels.containsAll(issueLabels)) {
List<String> unknownLabels = new ArrayList<>(issueLabels);
unknownLabels.removeAll(availableLabels);
throw new InvalidUserDataException("Unknown label(s): " + StringUtils.collectionToCommaDelimitedString(unknownLabels));
}
Milestone milestone = determineMilestone(repository);
List<Issue> existingUpgradeIssues = repository.findIssues(issueLabels, milestone);
List<Upgrade> upgrades = new InteractiveUpgradeResolver(new MavenMetadataVersionResolver(this.repositoryUrls), this.bom.getUpgrade().getPolicy(), getServices().get(UserInputHandler.class)).resolveUpgrades(this.bom.getLibraries());
Path buildFile = getProject().getBuildFile().toPath();
Path gradleProperties = new File(getProject().getRootProject().getProjectDir(), "gradle.properties").toPath();
UpgradeApplicator upgradeApplicator = new UpgradeApplicator(buildFile, gradleProperties);
for (Upgrade upgrade : upgrades) {
String title = "Upgrade to " + upgrade.getLibrary().getName() + " " + upgrade.getVersion();
Issue existingUpgradeIssue = findExistingUpgradeIssue(existingUpgradeIssues, upgrade);
if (existingUpgradeIssue != null) {
System.out.println(title + " (supersedes #" + existingUpgradeIssue.getNumber() + " " + existingUpgradeIssue.getTitle() + ")");
} else {
System.out.println(title);
}
try {
Path modified = upgradeApplicator.apply(upgrade);
int issueNumber = repository.openIssue(title, (existingUpgradeIssue != null) ? "Supersedes #" + existingUpgradeIssue.getNumber() : "", issueLabels, milestone);
if (existingUpgradeIssue != null) {
existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded"));
}
if (new ProcessBuilder().command("git", "add", modified.toFile().getAbsolutePath()).start().waitFor() != 0) {
throw new IllegalStateException("git add failed");
}
if (new ProcessBuilder().command("git", "commit", "-m", title + "\n\nCloses gh-" + issueNumber).start().waitFor() != 0) {
throw new IllegalStateException("git commit failed");
}
} catch (IOException ex) {
throw new TaskExecutionException(this, ex);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class MapNotationConverter method parseType.
@Override
public T parseType(Map values) throws UnsupportedNotationException {
Map<String, Object> mutableValues = new HashMap<>(Cast.uncheckedNonnullCast(values));
Set<String> missing = null;
ConvertMethod convertMethod = null;
Method method = null;
while (method == null) {
convertMethod = ConvertMethod.of(this.getClass());
// since we need access to the method and that it's weakly referenced
// we always need to double check that it hasn't been collected
method = convertMethod.getMethod();
}
Class<?>[] parameterTypes = method.getParameterTypes();
Object[] params = new Object[parameterTypes.length];
String[] keyNames = convertMethod.keyNames;
boolean[] optionals = convertMethod.nullables;
for (int i = 0; i < params.length; i++) {
String keyName = keyNames[i];
boolean optional = optionals[i];
Class<?> type = parameterTypes[i];
Object value;
if (type == String.class) {
value = get(mutableValues, keyName);
} else {
value = type.cast(mutableValues.get(keyName));
}
if (!optional && value == null) {
if (missing == null) {
missing = new TreeSet<>();
}
missing.add(keyName);
}
mutableValues.remove(keyName);
params[i] = value;
}
if (missing != null) {
// Throwing InvalidUserDataException here means that useful context information (including candidate formats, etc.) is not presented to the user
throw new InvalidUserDataException(String.format("Required keys %s are missing from map %s.", missing, values));
}
T result;
try {
result = Cast.uncheckedNonnullCast(method.invoke(this, params));
} catch (IllegalAccessException e) {
throw UncheckedException.throwAsUncheckedException(e);
} catch (InvocationTargetException e) {
throw UncheckedException.unwrapAndRethrow(e);
}
ConfigureUtil.configureByMap(mutableValues, result);
return result;
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class SelectorState method trackDetailsForOverrideMetadata.
private void trackDetailsForOverrideMetadata(DependencyState dependencyState) {
ClientModule nextClientModule = DefaultComponentOverrideMetadata.extractClientModule(dependencyState.getDependency());
if (nextClientModule != null && !nextClientModule.equals(clientModule)) {
if (clientModule == null) {
clientModule = nextClientModule;
} else {
throw new InvalidUserDataException(dependencyState.getDependency().getSelector().getDisplayName() + " has more than one client module definitions.");
}
}
changing = changing || dependencyState.getDependency().isChanging();
}
Aggregations