Skip to content

Commit

Permalink
#7: add Tag class with predefined tags (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Jan 16, 2024
1 parent 48e9dad commit f75bfa6
Show file tree
Hide file tree
Showing 23 changed files with 793 additions and 104 deletions.
564 changes: 564 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/common/Tag.java

Large diffs are not rendered by default.

59 changes: 4 additions & 55 deletions cli/src/main/java/com/devonfw/tools/ide/common/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,14 @@
import java.util.Set;

/**
* TODO hohwille This type ...
*
* Interface for an object that {@link #getTags() has} {@link Tag}s.
*/
public interface Tags {

/** {@link #getTags() Tag} for Java and JVM related tools. */
String TAG_JAVA = "java";

/** {@link #getTags() Tag} for build tools. */
String TAG_BUILD = "build";

/** {@link #getTags() Tag} for quality assurance (QA) tools. */
String TAG_QA = "qa";

/** {@link #getTags() Tag} for artificial intelligence (AI) and machine learning (ML) tools. */
String TAG_AI = "ai";

/** {@link #getTags() Tag} for documentation tools. */
String TAG_DOCUMENTATION = "doc";

/** {@link #getTags() Tag} for tools supporting AsciiDoc. */
String TAG_ASCIIDOC = "adoc";

/** {@link #getTags() Tag} for angular related tools. */
String TAG_ANGULAR = "angular";

/** {@link #getTags() Tag} for TypeScript related tools. */
String TAG_TYPE_SCRIPT = "ts";

/** {@link #getTags() Tag} for generic tools that increase productivity. */
String TAG_PRODUCTIVITY = "productivity";

/** {@link #getTags() Tag} for DotNet related tools. */
String TAG_DOT_NET = ".net";

/** {@link #getTags() Tag} for Python related tools. */
String TAG_PYTHON = "python";

/** {@link #getTags() Tag} for tools that actually represent an IDE (Integrated Development Environment). */
String TAG_IDE = "ide";

/** {@link #getTags() Tag} for tools providing a runtime environment (the core of a programming language). */
String TAG_RUNTIME = "runtime";

/**
* {@link #getTags() Tag} for cloud tools (e.g. CLI to manage infrastructure in the cloud). This is not limited to the
* hyper-scalers but also used for other platforms providing automation like openshift or even github.
* @return a {@link Set} with the tags classifying this object. E.g. for mvn (maven) the tags {@link Tag#JAVA java}
* and {@link Tag#BUILD build} could be associated.
*/
String TAG_CLOUD = "cloud";
Set<Tag> getTags();

/** {@link #getTags() Tag} for infrastructure-as-code (IAC) tools. */
String TAG_IAC = "iac";

/** {@link #getTags() Tag} for frameworks. */
String TAG_FRAMEWORK = "framework";

/**
* @return a {@link Set} with the tags classifying this object. E.g. for mvn (maven) the tags {@link #TAG_JAVA java}
* and {@link #TAG_BUILD build} could be associated.
*/
Set<String> getTags();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.devonfw.tools.ide.tool;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.io.FileAccess;
import com.devonfw.tools.ide.process.ProcessContext;
Expand All @@ -24,7 +25,7 @@ public abstract class GlobalToolCommandlet extends ToolCommandlet {
* @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of}
* method.
*/
public GlobalToolCommandlet(IdeContext context, String tool, Set<String> tags) {
public GlobalToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {

super(context, tool, tags);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.devonfw.tools.ide.tool;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Set;

import com.devonfw.tools.ide.commandlet.Commandlet;
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.io.FileAccess;
import com.devonfw.tools.ide.io.FileCopyMode;
import com.devonfw.tools.ide.log.IdeLogLevel;
import com.devonfw.tools.ide.repo.ToolRepository;
import com.devonfw.tools.ide.version.VersionIdentifier;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Set;

/**
* {@link ToolCommandlet} that is installed locally into the IDE.
*/
Expand All @@ -27,12 +28,11 @@ public abstract class LocalToolCommandlet extends ToolCommandlet {
* @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of}
* method.
*/
public LocalToolCommandlet(IdeContext context, String tool, Set<String> tags) {
public LocalToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {

super(context, tool, tags);
}


/**
* @return the {@link Path} where the tool is located (installed).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.devonfw.tools.ide.cli.CliException;
import com.devonfw.tools.ide.commandlet.Commandlet;
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.common.Tags;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariables;
Expand All @@ -31,7 +32,7 @@ public abstract class ToolCommandlet extends Commandlet implements Tags {
/** @see #getName() */
protected final String tool;

private final Set<String> tags;
private final Set<Tag> tags;

/** The commandline arguments to pass to the tool. */
public final StringListProperty arguments;
Expand All @@ -46,7 +47,7 @@ public abstract class ToolCommandlet extends Commandlet implements Tags {
* @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of}
* method.
*/
public ToolCommandlet(IdeContext context, String tool, Set<String> tags) {
public ToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {

super(context);
this.tool = tool;
Expand All @@ -73,7 +74,7 @@ protected String getBinaryName() {
}

@Override
public final Set<String> getTags() {
public final Set<Tag> getTags() {

return this.tags;
}
Expand Down
5 changes: 3 additions & 2 deletions cli/src/main/java/com/devonfw/tools/ide/tool/az/Azure.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.nio.file.Paths;
import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariables;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
Expand All @@ -22,7 +23,7 @@ public class Azure extends LocalToolCommandlet {
*/
public Azure(IdeContext context) {

super(context, "az", Set.of(TAG_CLOUD));
super(context, "az", Set.of(Tag.CLOUD));
}

@Override
Expand All @@ -34,6 +35,6 @@ public void postInstall() {
EnvironmentVariables typeVariables = variables.getByType(EnvironmentVariablesType.CONF);
typeVariables.set("AZURE_CONFIG_DIR", this.context.getConfPath().resolve(".azure").toString(), true);
typeVariables.save();
this.context.getFileAccess().symlink(Paths.get("wbin"), this.getToolPath().resolve("bin"));
this.context.getFileAccess().symlink(Paths.get("wbin"), getToolPath().resolve("bin"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import com.devonfw.tools.ide.cli.CliArgument;
import com.devonfw.tools.ide.cli.CliException;
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.log.IdeLogLevel;
import com.devonfw.tools.ide.process.ProcessContext;
Expand All @@ -32,7 +33,7 @@ public class Eclipse extends IdeToolCommandlet {
*/
public Eclipse(IdeContext context) {

super(context, "eclipse", Set.of(TAG_JAVA, TAG_IDE));
super(context, "eclipse", Set.of(Tag.ECLIPSE));
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion cli/src/main/java/com/devonfw/tools/ide/tool/gh/Gh.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;
Expand All @@ -18,7 +19,7 @@ public class Gh extends LocalToolCommandlet {
*/
public Gh(IdeContext context) {

super(context, "gh", Set.of(TAG_CLOUD));
super(context, "gh", Set.of(Tag.CLOUD));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;
Expand All @@ -19,7 +20,7 @@ public class Gradle extends LocalToolCommandlet {
*/
public Gradle(IdeContext context) {

super(context, "gradle", Set.of(TAG_JAVA, TAG_BUILD));
super(context, "gradle", Set.of(Tag.JAVA, Tag.BUILD));
}

@Override
Expand Down
7 changes: 4 additions & 3 deletions cli/src/main/java/com/devonfw/tools/ide/tool/helm/Helm.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.devonfw.tools.ide.tool.helm;

import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;

import java.util.Set;

/**
* {@link ToolCommandlet} for <a href="https://helm.sh/">Helm</a>, the package manager for Kubernetes.
*/
Expand All @@ -17,7 +18,7 @@ public class Helm extends LocalToolCommandlet {
*/
public Helm(IdeContext context) {

super(context, "helm", Set.of(TAG_CLOUD));
super(context, "helm", Set.of(Tag.KUBERNETES));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.stream.Stream;

import com.devonfw.tools.ide.cli.CliException;
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.io.FileAccess;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
Expand All @@ -38,10 +39,20 @@ public abstract class IdeToolCommandlet extends LocalToolCommandlet {
* @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of}
* method.
*/
public IdeToolCommandlet(IdeContext context, String tool, Set<String> tags) {
public IdeToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {

super(context, tool, tags);
assert (tags.contains(TAG_IDE));
assert (hasIde(tags));
}

private boolean hasIde(Set<Tag> tags) {

for (Tag tag : tags) {
if (tag.isAncestorOf(Tag.IDE)) {
return true;
}
}
throw new IllegalStateException("Tags of IdeTool hat to be connected with tag IDE: " + tags);
}

private Map<String, PluginDescriptor> getPluginsMap() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.log.IdeLogger;

Expand All @@ -25,7 +25,7 @@ public class PluginDescriptorImpl implements PluginDescriptor {

private final boolean active;

private final Set<String> tags;
private final Set<Tag> tags;

/**
* The constructor.
Expand All @@ -36,7 +36,7 @@ public class PluginDescriptorImpl implements PluginDescriptor {
* @param active the {@link #isActive() active flag}.
* @param tags the {@link #getTags() tags}.
*/
public PluginDescriptorImpl(String id, String name, String url, boolean active, Set<String> tags) {
public PluginDescriptorImpl(String id, String name, String url, boolean active, Set<Tag> tags) {

super();
this.id = id;
Expand Down Expand Up @@ -71,7 +71,7 @@ public boolean isActive() {
}

@Override
public Set<String> getTags() {
public Set<Tag> getTags() {

return this.tags;
}
Expand Down Expand Up @@ -100,12 +100,7 @@ public static PluginDescriptor of(Path propertiesFile, IdeLogger logger, boolean
}
boolean active = getBoolean(properties, "active", "plugin_active", propertiesFile, logger);
String tagsCsv = getString(properties, "tags", "plugin_tags");
Set<String> tags;
if ((tagsCsv == null) || tagsCsv.isBlank()) {
tags = Collections.emptySet();
} else {
tags = Set.of(tagsCsv.split(","));
}
Set<Tag> tags = Tag.parseCsv(tagsCsv);
return new PluginDescriptorImpl(id, name, url, active, tags);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet;
import com.devonfw.tools.ide.tool.ide.PluginDescriptor;
Expand All @@ -19,7 +20,7 @@ public class Intellij extends IdeToolCommandlet {
*/
public Intellij(IdeContext context) {

super(context, "intellij", Set.of(TAG_JAVA, TAG_IDE));
super(context, "intellij", Set.of(Tag.INTELLIJ));
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion cli/src/main/java/com/devonfw/tools/ide/tool/java/Java.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;
Expand All @@ -18,7 +19,7 @@ public class Java extends LocalToolCommandlet {
*/
public Java(IdeContext context) {

super(context, "java", Set.of(TAG_JAVA, TAG_RUNTIME));
super(context, "java", Set.of(Tag.JAVA, Tag.RUNTIME));
}

}
Loading

0 comments on commit f75bfa6

Please sign in to comment.