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

Resubmit #149 with fixes #182

Closed
wants to merge 5 commits into from
Closed

Conversation

kitbellew
Copy link
Contributor

Description

Fixes #158.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Built the plugin locally, changed this project's pom to point to the local snapshot, observed the list of formatted files output.
  • Also, added unit tests for the new logic.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor Author

@kitbellew kitbellew left a comment

Choose a reason for hiding this comment

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

@SimonJPegg perhaps this time's the charm.

@@ -43,12 +44,10 @@
* then we consider the value in {@code <branch>} tag as a command to run and the output will be used as the actual branch */
@Parameter(property = "format.branch", defaultValue = "master")
private String branch;
@Parameter(readonly = true, defaultValue = "${project}")
@Parameter(property = "project", readonly = true, required = true, defaultValue = "${project}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

compared to #149: added property = "project" as some online sources insist that it's required with the switch from maven-project to maven-core.

however, i also tested with setting only one of property = "project" and defaultValue = "${project}", and all three versions seem to work. looks like this was not the culprit, but decided to keep both just in case.

@@ -0,0 +1,54 @@
package org.antipathy.mvn_scalafmt
Copy link
Contributor Author

Choose a reason for hiding this comment

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

compared to #149: moved the bulk of the logic from FormatMojo.getSources to this source, along with unit tests.


private def getCanonicalFile(dir: String): File = {
val relfile = new File(dir)
val absfile = if (relfile.isAbsolute) relfile else new File(project.getBasedir, dir)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

compared to #149: the check for .isAbsolute looks to be the primary reason why that commit failed. when testing that build locally, i must not have observed that the list of formatted files was empty (because i didn't expect it).

it took me a while to track this down; I suspected that the move to maven-core was the culprit, not this method; neither user who commented on #158 included the full error message (rather than ...), or it would have been obvious that the project directory had been repeated.


private def appendAlternative(altDirs: JList[String], outputDir: String): Unit = {
val outputPath = getCanonicalFile(outputDir).toPath
sources ++= altDirs.asScala.map(getCanonicalFile).filter(!_.toPath.startsWith(outputPath))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

compare to #149: added the logic excluding generated files (those under the output dirs).

@kitbellew kitbellew changed the title 149 Resubmit #149 with fixes Jan 17, 2022
@kitbellew kitbellew force-pushed the 149 branch 2 times, most recently from 72aa341 to df35228 Compare January 17, 2022 03:45
project.getBasedir().toPath.resolve(dir).toFile().getCanonicalFile()

private def getCanonicalFile(dir: File): File =
project.getBasedir().toPath.resolve(dir.toPath).toFile().getCanonicalFile()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to Path.resolve because of codacy. this replaces the code that failed in #149 because of unexpected behaviour of new File(a, b).

@github-actions
Copy link

PR appears to be stale

@kitbellew
Copy link
Contributor Author

generally ready for review

@github-actions github-actions bot closed this Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Release 2.13-1.0.1625170289.4e4665d is broken
1 participant