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

PLANNER-1299 #19

Closed
wants to merge 0 commits into from
Closed

PLANNER-1299 #19

wants to merge 0 commits into from

Conversation

danielefiungo
Copy link
Contributor

One mvn build that delegates to the frontend build

.gitignore Outdated Show resolved Hide resolved
.idea/misc.xml Outdated Show resolved Hide resolved
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>
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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:

  1. Use the .eslint file per project, with eslint plugin for IDEs with disabled Javascript on KIE Conventions (if possible)

  2. 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

Copy link
Member

@yurloc yurloc Oct 5, 2018

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?

Copy link
Contributor Author

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.

<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-examples</artifactId>
<version>7.12.0-SNAPSHOT</version>
Copy link
Contributor

@ge0ffrey ge0ffrey Oct 4, 2018

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.

Copy link
Member

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).

<dependency>
<groupId>org.optaweb.tsp</groupId>
<artifactId>optaweb-tsp-ui</artifactId>
<version>0.0.1-SNAPSHOT</version>
Copy link
Contributor

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.

</build>
<repositories>
<repository>
<id>jboss-snapshot</id>
Copy link
Contributor

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.

@@ -1,5 +1,6 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

### Maven Frontend Plugin ###
node/
Copy link
Contributor

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?

Copy link
Contributor Author

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


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Copy link
Contributor

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

<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${version.frontend-maven-plugin}</version>
Copy link
Contributor

@ge0ffrey ge0ffrey Oct 4, 2018

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>
Copy link
Contributor

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>
Copy link
Contributor

@ge0ffrey ge0ffrey Oct 4, 2018

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?

Copy link
Member

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).

@ge0ffrey
Copy link
Contributor

ge0ffrey commented Oct 4, 2018

@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:

  • consistency across optaweb-*, optaplanner, kie, jboss.
  • reduce code duplication (e.g. mvn parents etc)
  • avoid merge conflicts (e.g. code style and gitignore generated files)

@ge0ffrey
Copy link
Contributor

ge0ffrey commented Oct 4, 2018

@danielefiungo Good start, please take a look at the comments and let us know when they're fixed.

</dependency>
</dependencies>
</profile>
</profiles>
Copy link
Member

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?

Copy link
Contributor Author

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?

"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz",
"integrity": "sha1-YaajIBBiKvoHljvzJSA88SI51gQ=",
"dev": true
},
Copy link
Member

@yurloc yurloc Oct 5, 2018

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.

Copy link
Contributor Author

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.

Copy link
Member

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!

<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
Copy link
Member

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?

Copy link
Contributor Author

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

@@ -0,0 +1,551 @@
{
Copy link
Member

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants