-
Notifications
You must be signed in to change notification settings - Fork 123
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
PLANNER-1299 #19
PLANNER-1299 #19
Conversation
optaweb-tsp-planner/pom.xml
Outdated
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<modelVersion>4.0.0</modelVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielefiungo please set your xml indentation to 2 spaces.
We have Intellij/Eclipse code style files here:
https://github.com/kiegroup/droolsjbpm-build-bootstrap/tree/master/ide-configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've applied the coding style.
Warning: the create-react-app project came with eslint configuration that imply a code format.
In our case (tab-size) this don't create problems 2 space match with eslint style, but some other rule can clash with kiegroup standard code format, in this case the "eject" can be used to address the problem with all the related downsides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found a rule conflict,
file : .js rule: indent ESLint CRA 2 spaces vs KIE Conventions 4 spaces
I've edited .eslint.json to adopt KIE Convention but this can became tricky to maintain and adapt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielefiungo KIE Conventions are Java-centric with the default indentation of 4 spaces. Special code style requirements for other languages need to override the default indentation. For example XML language overrides indentation to 2 spaces. I think we need to do the same for JavaScript and TypeScript as the standard indentation for JavaScript code seems to be 2 spaces. Most of the code samples I've seen so far use 2 spaces indentation [1]. What's your opinion, Daniele?
[1] @tiagobento uses 2 space indentation in his proof-of-concept app too: https://github.com/tiagobento/appformer-js/blob/master/packages/core/src/internal/Root.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, using an already widely adopted coding style is a plus.
The only concern is how the linting and formatting of code is done, having two different components ESLint and Intellij/Eclipse.
I think we have at least two options:
-
Use the .eslint file per project, with eslint plugin for IDEs with disabled Javascript on KIE Conventions (if possible)
-
Use both trying to obtain the same (if possible)
Isn't only an indent problem:
import React, {Component} from 'react';
// KIE OK
// eslint ERROR : A space is required after '{'. (object-curly-spacing)
import React, { Component } from 'react';
Even JSX code there is indent issue problem.
Probably when the project will grow we'll have some other mismatch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielefiungo .eslintrc.json
is the single source of truth. It's based on airbnb style with just a few necessary tweaks. IDEA style need to be adjusted to produce code that has no ESLint errors. That's basically the option 2 that you have proposed. Do you agree with this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree ESLint is the best option.
optaweb-tsp-planner/pom.xml
Outdated
<dependency> | ||
<groupId>org.optaplanner</groupId> | ||
<artifactId>optaplanner-examples</artifactId> | ||
<version>7.12.0-SNAPSHOT</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurloc Do it similar like optaweb-employee-rostering:
https://github.com/kiegroup/optaweb-employee-rostering/blob/master/pom.xml
Introduce a maven property version.org.optaplanner, use the optaplanner-bom in dependencyManagement, etc Applies to all dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but out of scope of this PR (note taken).
optaweb-tsp-planner/pom.xml
Outdated
<dependency> | ||
<groupId>org.optaweb.tsp</groupId> | ||
<artifactId>optaweb-tsp-ui</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ${project.version} to avoid a pita during MichaelB's releasing (he needs to upgrade the version numbers then).
Better yet, all internal GAV's should be in the depenency management, so having to declare a <version>
element to get begin with isn't needed. See optaplanner-examples pom.xml in optaplanner repo.
optaweb-tsp-planner/pom.xml
Outdated
</build> | ||
<repositories> | ||
<repository> | ||
<id>jboss-snapshot</id> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the root pom.xml should have a repositories element. That should be exactly the same as the one in optaweb-employee-rostering.
optaweb-tsp-ui/.gitignore
Outdated
@@ -1,5 +1,6 @@ | |||
# See https://help.github.com/ignore-files/ for more about ignoring files. | |||
|
|||
### Maven Frontend Plugin ### | |||
node/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielefiungo Can we put the node output under the target directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll add the required config
optaweb-tsp-ui/pom.xml
Outdated
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pom should extend the root pom. Similar to how optaweb-employee-rostering-shared has a parent optaweb-employee-rostering. When that parent is there, all these properties should be moved there, see the root pom of optaweb-employee-rostering
optaweb-tsp-ui/pom.xml
Outdated
<plugin> | ||
<groupId>com.github.eirslett</groupId> | ||
<artifactId>frontend-maven-plugin</artifactId> | ||
<version>${version.frontend-maven-plugin}</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version and most configuration goes in pluginManagement in root pom, see optaweb-employee-rostering root pom
pom.xml
Outdated
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.optaweb.tsp</groupId> | ||
<artifactId>optaweb-tsp-parent</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
artfictId of any pom should match the directory name (unless there's a good reason not to do that), let's name this optaweb-traveling-salesman.
pom.xml
Outdated
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.optaweb.tsp</groupId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurloc Does this groupId match the java packages? Is it similar in style to how optaweb-employee-rostering does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ge0ffrey Yes, Java classes' packages begin with this groupId, e.g. org.optaweb.tsp.optawebtspplanner.OptawebTspPlannerApplication
(packges deeper than org.optaweb.tsp
still need to be improved).
@danielefiungo @yurloc I ran through this PR review rather quickly. If the motivation behind any of the comments isn't clear automatically, please let me know and I 'll include a decent motivation behind the reasons for me asking for that particular change. Generally, we want:
|
@danielefiungo Good start, please take a look at the comments and let us know when they're fixed. |
optaweb-tsp-planner/pom.xml
Outdated
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielefiungo What is the reason for having the dependency in a profile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UI can be deployed on a simple http server and include static resources inside BE can be optionally disabled in CI when UI is deployed separately.
@yurloc Make sense for you?
optaweb-tsp-ui/package-lock.json
Outdated
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz", | ||
"integrity": "sha1-YaajIBBiKvoHljvzJSA88SI51gQ=", | ||
"dev": true | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielefiungo Can you explain these changes in package-lock.json
? If I run mvn clean install
locally, they get removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably is related to test implementation I've add:
"enzyme": "^3.6.0" and "enzyme-adapter-react-16" without commit package.json to keep it separate.
I'll revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense. Thank you!
optaweb-tsp-planner/pom.xml
Outdated
<excludeTransitive>true</excludeTransitive> | ||
</configuration> | ||
</execution> | ||
</executions> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielefiungo This has an unpleasant side effect. It unpacks all of this project's dependencies (including Spring Boot starters, H2 database, optaplanner examples) producing a sort of fat JAR. Some resources get overridden (e.g logback.xml). Can you configure the plugin to only unpack the optaweb-tsp-ui
dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created and removed a review by mistake, anyway ...
the configuration prevent a minor side effect related to the unpack of UI jar that can be addressed with a mvn clean, is minor compared your suggested side effects
package-lock.json
Outdated
@@ -0,0 +1,551 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielefiungo I think this file was committed by mistake. There is no package.json
in the root directory so there should be no package-lock.json
I would say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad, probably I had run npm ... on the wrong directory.
One mvn build that delegates to the frontend build