Skip to content

Commit

Permalink
revert version attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
alfeilex committed Jan 19, 2024
1 parent e0e6c51 commit 147799a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ public interface PluginDescriptor extends Tags {
*/
String getName();

/**
* @return the optional plugin version.
*/
String getVersion();

/**
* @return the optional plugin URL (download/update site).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public class PluginDescriptorImpl implements PluginDescriptor {

private final String name;

private final String version;

private final String url;

private final boolean active;
Expand All @@ -34,17 +32,15 @@ public class PluginDescriptorImpl implements PluginDescriptor {
*
* @param id the {@link #getId() ID}.
* @param name the {@link #getName() name}.
* @param version the {@link #getVersion() URL}.
* @param url the {@link #getUrl() URL}.
* @param active the {@link #isActive() active flag}.
* @param tags the {@link #getTags() tags}.
*/
public PluginDescriptorImpl(String id, String name, String version, String url, boolean active, Set<Tag> tags) {
public PluginDescriptorImpl(String id, String name, String url, boolean active, Set<Tag> tags) {

super();
this.id = id;
this.name = name;
this.version = version;
this.url = url;
this.active = active;
this.tags = tags;
Expand All @@ -62,12 +58,6 @@ public String getName() {
return this.name;
}

@Override
public String getVersion() {

return this.version;
}

@Override
public String getUrl() {

Expand Down Expand Up @@ -104,15 +94,14 @@ public static PluginDescriptor of(Path propertiesFile, IdeLogger logger, boolean
throw new IllegalStateException("Failed to load properties " + propertiesFile, e);
}
String id = getString(properties, "id", "plugin_id");
String version = getString(properties, "version", "plugin_version");
String url = getString(properties, "url", "plugin_url");
if (needUrl && ((url == null) || url.isBlank())) {
logger.warning("Missing plugin URL in {}", propertiesFile);
}
boolean active = getBoolean(properties, "active", "plugin_active", propertiesFile, logger);
String tagsCsv = getString(properties, "tags", "plugin_tags");
Set<Tag> tags = Tag.parseCsv(tagsCsv);
return new PluginDescriptorImpl(id, name, version, url, active, tags);
return new PluginDescriptorImpl(id, name, url, active, tags);
}

private static boolean getBoolean(Properties properties, String key, String legacyKey, Path propertiesFile,
Expand Down
18 changes: 1 addition & 17 deletions cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
Expand Down Expand Up @@ -38,27 +37,12 @@ public boolean install(boolean silent) {
public void installPlugin(PluginDescriptor plugin) {

Path mavenPlugin = this.context.getSoftwarePath().resolve(this.tool).resolve("lib/ext/" + plugin.getName() + ".jar");
this.context.getFileAccess().download(getPluginUrl(plugin), mavenPlugin);
this.context.getFileAccess().download(plugin.getUrl(), mavenPlugin);
if (Files.exists(mavenPlugin)) {
this.context.success("Successfully added {} to {}", plugin.getName(), mavenPlugin.toString());
} else {
this.context.warning("Plugin {} has wrong properties\n" //
+ "Please check the plugin properties file in {}", mavenPlugin.getFileName(), mavenPlugin.toAbsolutePath());
}
}

private String getPluginUrl(PluginDescriptor plugin) {

if (plugin.getUrl() != null) {
return plugin.getUrl();
} else {
return "https://repo1.maven.org/maven2/fr/jcgay/maven/" + plugin.getName() + "/" + getPluginVersion(plugin.getVersion()) + "/" + plugin.getName()
+ "-" + getPluginVersion(plugin.getVersion()) + ".jar";
}
}

private String getPluginVersion(String version) {

return Objects.requireNonNullElse(version, "latest");
}
}

0 comments on commit 147799a

Please sign in to comment.