Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#317: added BuildCommandlet #340

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

jan-vcapgemini
Copy link
Contributor

@jan-vcapgemini jan-vcapgemini commented May 17, 2024

Fixes: #317

Implements

  • added BuildCommandlet for mvn, gradle and npm
  • added BuildCommandletTests
  • added documentation for build and build tools (mvn, npm, yarn)
  • added TOOL_BUILD_OPTS environment variables and handling

added BuildCommandlet
added BuildCommandletTest
added BuildCommandletTest resources
@jan-vcapgemini jan-vcapgemini self-assigned this May 17, 2024
@jan-vcapgemini jan-vcapgemini added enhancement New feature or request npm node package manager mvn related to apache maven build tool gradle Gralde build tool commandlet labels May 17, 2024
set npm test to parameterized to enforce windows only
# Conflicts:
#	cli/src/main/resources/nls/Ide.properties
#	cli/src/main/resources/nls/Ide_de.properties
added missing val path property to nls files
adjusted assertLogMessage (removed parameterized test)
@coveralls
Copy link
Collaborator

coveralls commented May 21, 2024

Pull Request Test Coverage Report for Build 9301625045

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.6%) to 60.342%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java 3 89.77%
Totals Coverage Status
Change from base Build 9275378992: 0.6%
Covered Lines: 4733
Relevant Lines: 7542

💛 - Coveralls

Copy link
Contributor

@aBega2000 aBega2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR. Everything seems fine to me.

Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jan-vcapgemini thanks for this PR. You did a great job implementing this and especially testing this commandlet with all its scenarios. 👍

However, there is some concern with the CLI properties and related behavior that differs from devonfw-ide. Please have a look at my review comments.

changed PathProperty to multivalued StringPropertery
adjusted tests
added build documentation
added mvn documentation
added npm documentation
added yarn documentation
replaced devon with ide
added default build options environment variables and handling
added gradle documentation
added default options to documentations
added test for default options
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jan-vcapgemini Thanks for your update. You did some great improvements 👍
Probably for complex stories I should next time do the reverse-engineering myself and write everything explicitly as requirements and acceptance criteria into the story. Due to lack of time, I created all the commandlet stories via copy&paste with a simple link to the old code and expected the developer to do the reverse-engineering. As it turns out this seems to be more tricky than expected...
Please have a look at my review comments.

Path buildPath = this.context.getCwd();
String[] defaultToolOptions = new String[0];

if (buildPath != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if buildPath (aka cwd) would be null then we do nothing?
IMHO this will never happen but if we want to handle this explicitly, I would rather do something like this:

if (buildPath == null) {
  throw new CliException("Missing current working directory!");
}


defaultToolOptions = getDefaultToolOptions(NPM_BUILD_OPTS.getName());
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again we have no else here. So what if neither pom.xml nor build.gradle nor package.json was found?
Then we silently do nothing?
Again I would recommend explicit error handling:

Suggested change
}
} else {
throw new CliException("Could not find build descriptor - no pom.xml, build.gradle, or package.json found!");
}

@@ -49,6 +49,18 @@ public interface IdeVariables {

/** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getWorkspaceName() WORKSPACE}. */

/** {@link VariableDefinition} for default build options of mvn */
VariableDefinitionString MVN_BUILD_OPTS = new VariableDefinitionString("MVN_BUILD_OPTS", null, c -> "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As pointed out: https://github.com/devonfw/ide/blob/cdf4af5de21489f3fdcbfdab41af858822e0d598/scripts/src/main/resources/scripts/command/mvn#L354

Suggested change
VariableDefinitionString MVN_BUILD_OPTS = new VariableDefinitionString("MVN_BUILD_OPTS", null, c -> "");
VariableDefinitionString MVN_BUILD_OPTS = new VariableDefinitionString("MVN_BUILD_OPTS", null, c -> "clean deploy");

VariableDefinitionString MVN_BUILD_OPTS = new VariableDefinitionString("MVN_BUILD_OPTS", null, c -> "");

/** {@link VariableDefinition} for default build options of npm */
VariableDefinitionString NPM_BUILD_OPTS = new VariableDefinitionString("NPM_BUILD_OPTS", null, c -> "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one seems more tricky - see
https://github.com/devonfw/ide/blob/cdf4af5de21489f3fdcbfdab41af858822e0d598/scripts/src/main/resources/scripts/command/npm#L118-L124
and
https://github.com/devonfw/ide/blob/cdf4af5de21489f3fdcbfdab41af858822e0d598/scripts/src/main/resources/scripts/command/npm#L92-L98

Maybe we should address this one in a separate PR and merge as is? So far this would be my suggestion to make better progress... So either create an issue for this and link here as comment so I can resolve or already address in this PR adding even more new features and complexity.

VariableDefinitionString NPM_BUILD_OPTS = new VariableDefinitionString("NPM_BUILD_OPTS", null, c -> "");

/** {@link VariableDefinition} for default build options of gradle */
VariableDefinitionString GRADLE_BUILD_OPTS = new VariableDefinitionString("GRADLE_BUILD_OPTS", null, c -> "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again see here: https://github.com/devonfw/ide/blob/cdf4af5de21489f3fdcbfdab41af858822e0d598/scripts/src/main/resources/scripts/command/gradle#L91

Suggested change
VariableDefinitionString GRADLE_BUILD_OPTS = new VariableDefinitionString("GRADLE_BUILD_OPTS", null, c -> "");
VariableDefinitionString GRADLE_BUILD_OPTS = new VariableDefinitionString("GRADLE_BUILD_OPTS", null, c -> "clean dist");

VariableDefinitionString GRADLE_BUILD_OPTS = new VariableDefinitionString("GRADLE_BUILD_OPTS", null, c -> "");

/** {@link VariableDefinition} for default build options of yarn */
VariableDefinitionString YARN_BUILD_OPTS = new VariableDefinitionString("YARN_BUILD_OPTS", null, c -> "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NODE_VERSION=v18.19.1
NPM_VERSION=9.9.2
GRADLE_VERSION=8.7
MVN_BUILD_OPTS=clean install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default that is supposed to be build-in. Either remove or override with something else to test the overriding mechanism.

@@ -0,0 +1,12 @@
:toc:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in our meetings we do not want to come back to having help documentation on github in asciidoc.
This has many disadvantages (not available offline, esp. not accurate if the installed release differs from the latest documentation in development, no localization, not intuitive for CLI users, etc.).
Simply use your invest to put this into the CLI help output. Also please add the new variables to the variables.adoc. Then you can remove these 5 added adocs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this we already agreed in the team to add yet another help property for the detailed description of a commandlet.
So ide help «commandlet» will not only print cmd.build but also cmd.build.detail.
I can prepare the PR for this change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented:
#389

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commandlet enhancement New feature or request gradle Gralde build tool mvn related to apache maven build tool npm node package manager
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Implement Commandlet for build
4 participants