use of com.antfortune.freeline.idea.models.ArtifactDependencyModelWrapper in project freeline by alibaba.
the class UpdateAction method resultHandle.
/**
* 处理结果
*
* @param entity
* @param gradleBuildModels
*/
private void resultHandle(final GradleDependencyEntity entity, final Map<GradleBuildModel, List<ArtifactDependencyModel>> gradleBuildModels) {
String localVersion = null;
StringBuilder builder = new StringBuilder();
for (GradleBuildModel file : gradleBuildModels.keySet()) {
List<ArtifactDependencyModel> models = gradleBuildModels.get(file);
for (ArtifactDependencyModel dependencyModel1 : models) {
ArtifactDependencyModelWrapper dependencyModel = new ArtifactDependencyModelWrapper(dependencyModel1);
if (isClasspathLibrary(dependencyModel) || isDependencyLibrary(dependencyModel)) {
if (isClasspathLibrary(dependencyModel)) {
localVersion = dependencyModel.version();
}
builder.append(dependencyModel.configurationName()).append(" '").append(dependencyModel.group()).append(":").append(dependencyModel.name()).append(":").append(dependencyModel.version()).append("'").append("<br/>");
}
}
}
if (Utils.notEmpty(localVersion)) {
int compare = localVersion.compareTo(entity.getVersion());
final CheckUpdateDialog dialog = new CheckUpdateDialog();
dialog.getButtonOK().setEnabled(compare < 0);
dialog.setServerVersion(entity.getGroupId(), entity.getArtifactId(), entity.getVersion());
dialog.setServerUpdateTime(entity.getUpdateTime());
dialog.setLocalVersion(builder.toString());
dialog.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateAction(entity.getVersion(), gradleBuildModels);
dialog.dispose();
}
});
dialog.showDialog();
} else {
NotificationUtils.infoNotification("please add freeline dependency first");
}
}
use of com.antfortune.freeline.idea.models.ArtifactDependencyModelWrapper in project freeline by alibaba.
the class UpdateAction method updateAction.
/**
* 更新操作
*
* @param newVersion
* @param gradleBuildModels
*/
protected void updateAction(final String newVersion, final Map<GradleBuildModel, List<ArtifactDependencyModel>> gradleBuildModels) {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
for (GradleBuildModel file : gradleBuildModels.keySet()) {
List<ArtifactDependencyModel> models = gradleBuildModels.get(file);
for (ArtifactDependencyModel dependencyModel1 : models) {
ArtifactDependencyModelWrapper dependencyModel = new ArtifactDependencyModelWrapper(dependencyModel1);
if (isClasspathLibrary(dependencyModel)) {
dependencyModel1.setVersion(newVersion);
}
if (isDependencyLibrary(dependencyModel)) {
file.dependencies().remove(dependencyModel1);
}
}
file.applyChanges();
}
GradleUtil.executeTask(currentProject, "initFreeline", "-Pmirror", new ExternalSystemTaskNotificationListenerAdapter() {
@Override
public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
super.onTaskOutput(id, text, stdOut);
}
});
}
});
}
});
}
Aggregations