-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/396-tool-usage-help
- Loading branch information
Showing
74 changed files
with
1,291 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ | |
*.tar binary | ||
*.bz2 binary | ||
*.gz binary | ||
|
||
# special handling for test files | ||
studio64.exe text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
-Drevision=2024.06.002-alpha-SNAPSHOT | ||
-Drevision=2024.07.001-alpha-SNAPSHOT |
91 changes: 91 additions & 0 deletions
91
cli/src/main/java/com/devonfw/tools/ide/commandlet/BuildCommandlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.devonfw.tools.ide.commandlet; | ||
|
||
import com.devonfw.tools.ide.cli.CliException; | ||
import com.devonfw.tools.ide.context.IdeContext; | ||
import com.devonfw.tools.ide.property.StringProperty; | ||
import com.devonfw.tools.ide.tool.ToolCommandlet; | ||
import com.devonfw.tools.ide.tool.gradle.Gradle; | ||
import com.devonfw.tools.ide.tool.mvn.Mvn; | ||
import com.devonfw.tools.ide.tool.npm.Npm; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import static com.devonfw.tools.ide.variable.IdeVariables.GRADLE_BUILD_OPTS; | ||
import static com.devonfw.tools.ide.variable.IdeVariables.MVN_BUILD_OPTS; | ||
import static com.devonfw.tools.ide.variable.IdeVariables.NPM_BUILD_OPTS; | ||
|
||
/** | ||
* Build tool {@link Commandlet} for automatically detecting build configuration files and running the respective tool. | ||
*/ | ||
public class BuildCommandlet extends Commandlet { | ||
|
||
/** | ||
* The arguments to build with. | ||
*/ | ||
public StringProperty arguments; | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param context the {@link IdeContext}. | ||
*/ | ||
public BuildCommandlet(IdeContext context) { | ||
|
||
super(context); | ||
addKeyword(getName()); | ||
this.arguments = add(new StringProperty("", false, true, "args")); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
|
||
return "build"; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
|
||
Path buildPath = this.context.getCwd(); | ||
String[] defaultToolOptions = new String[0]; | ||
|
||
if (buildPath == null) { | ||
throw new CliException("Missing current working directory!"); | ||
} | ||
|
||
ToolCommandlet commandlet = null; | ||
if (Files.exists(buildPath.resolve("pom.xml"))) { | ||
commandlet = this.context.getCommandletManager().getCommandlet(Mvn.class); | ||
defaultToolOptions = getDefaultToolOptions(MVN_BUILD_OPTS.getName()); | ||
} else if (Files.exists(buildPath.resolve("build.gradle"))) { | ||
commandlet = this.context.getCommandletManager().getCommandlet(Gradle.class); | ||
defaultToolOptions = getDefaultToolOptions(GRADLE_BUILD_OPTS.getName()); | ||
} else if (Files.exists(buildPath.resolve("package.json"))) { | ||
if (Files.exists(buildPath.resolve("yarn.lock"))) { | ||
// TODO: add yarn here | ||
} else { | ||
commandlet = this.context.getCommandletManager().getCommandlet(Npm.class); | ||
|
||
defaultToolOptions = getDefaultToolOptions(NPM_BUILD_OPTS.getName()); | ||
} | ||
} else { | ||
throw new CliException("Could not find build descriptor - no pom.xml, build.gradle, or package.json found!"); | ||
} | ||
|
||
if (this.arguments.asArray().length != 0) { | ||
defaultToolOptions = this.arguments.asArray(); | ||
} | ||
|
||
if (commandlet != null) { | ||
commandlet.runTool(null, defaultToolOptions); | ||
} | ||
|
||
} | ||
|
||
private String[] getDefaultToolOptions(String buildOptionName) { | ||
|
||
String[] defaultToolOptions; | ||
defaultToolOptions = this.context.getVariables().get(buildOptionName).split(" "); | ||
return defaultToolOptions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.