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

Add enforcer rule to detect if extension misses description in pom #6335

Closed

Conversation

maxandersen
Copy link
Member

@maxandersen maxandersen commented Dec 23, 2019

adds simple enforcer check if build has an extensions.yaml it should at least also have a proper description in pom.xml that is not similar to what is in the parent.

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

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

LGTM

@geoand geoand requested a review from gsmet December 24, 2019 09:16
@gsmet gsmet changed the title Add enforcer rule to detect if extension misses description in pom. Add enforcer rule to detect if extension misses description in pom Dec 24, 2019
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

I removed the description of the Hibernate ORM extension (the one in the runtime artifact) and the build didn't fail.

I checked the parent of this extension in case it would have a meaningful description but AFAICS it doesn't.

Did I miss something?

@gsmet
Copy link
Member

gsmet commented Dec 24, 2019

@gastaldi have you tested this PR before approving? Because I can't get it to fail as expected.

@gsmet
Copy link
Member

gsmet commented Dec 24, 2019

@gastaldi if so, can you tell me which extension you tested so that I can check what's different with the one I tested. Thanks.

@gastaldi
Copy link
Contributor

@gsmet Yes, I've tested before approving it.

  1. Go to extensions/jgit/runtime and delete the <description> element
  2. Run mvn clean install
  3. See the following output:
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< io.quarkus:quarkus-jgit >-----------------------
[INFO] Building Quarkus - JGit - Runtime 999-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ quarkus-jgit ---
[INFO] Deleting /home/ggastald/workspace/quarkus/extensions/jgit/runtime/target
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce) @ quarkus-jgit ---
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.EvaluateBeanshell failed with message:
Description in pom.xml seem to be same as build-parent. This description is used by default to describe the extension in code.quarkus.io, tools and in repository browsers. Please set a unique description in pom.xml.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.944 s
[INFO] Finished at: 2019-12-24T08:30:30-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M2:enforce (enforce) on project quarkus-jgit: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@gastaldi
Copy link
Contributor

@gsmet the same happens with extensions/hibernate-orm/runtime, so I am not sure what you did to not fail the build:

➜  runtime git:(enforceextdescription) ✗ mvn clean install 
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< io.quarkus:quarkus-hibernate-orm >------------------
[INFO] Building Quarkus - Hibernate ORM - Runtime 999-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ quarkus-hibernate-orm ---
[INFO] Deleting /home/ggastald/workspace/quarkus/extensions/hibernate-orm/runtime/target
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce) @ quarkus-hibernate-orm ---
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.EvaluateBeanshell failed with message:
Description in pom.xml seem to be same as build-parent. This description is used by default to describe the extension in code.quarkus.io, tools and in repository browsers. Please set a unique description in pom.xml.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.589 s
[INFO] Finished at: 2019-12-24T08:36:49-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M2:enforce (enforce) on project quarkus-hibernate-orm: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@maxandersen
Copy link
Member Author

Weird I tested on qute and arc. All failed when I removed the description.

@gsmet
Copy link
Member

gsmet commented Dec 24, 2019

@gastaldi yeah, that's why I asked. It looked suspicious as the code looked right.

I checked several times I had the commit and that the description was gone. I will check again.

@gsmet
Copy link
Member

gsmet commented Dec 24, 2019

So... in the end everyone is right:

  • the enforcer rule works when you specifically run mvn clean install -DskipTests -DskipITs in the runtime directory of an extension (which is what George did)
  • it doesn't work when you run a full mvn clean install -DskipTests -DskipITs at the root of the project (which is what I did)

Can one of you check my observations?

@maxandersen
Copy link
Member Author

Weird. I tested full build with missing description and failed for me. I'll try when back at laptop after Xmas.

@gsmet
Copy link
Member

gsmet commented Dec 24, 2019

Yes, we're not in a hurry.

I checked another time dropping the JGit + Hibernate ORM descriptions and the build passes.

@maxandersen
Copy link
Member Author

xmas dinner over; can confirm I see the behaviour @gsmet sees too. investigating.

@maxandersen
Copy link
Member Author

the check for quarkus-extension.yaml was not using project.base.dir resulting it to only work when done within a runtime dir.

added project.basedir so it should now work.

I must have done the multimodule tests before I added that check, sorry about that; but now @gsmet\s test case should definitely fail with my latest push.

@gsmet gsmet force-pushed the enforceextdescription branch from 84d034a to 5f9acc4 Compare January 2, 2020 10:44
@gsmet
Copy link
Member

gsmet commented Jan 2, 2020

@maxandersen the rule seems OK now. I pushed some additional changes to fix the issues it reported (GH doesn't respect the commit ordering but I moved them before the rule addition so that the build doesn't get broken).

@gsmet
Copy link
Member

gsmet commented Jan 3, 2020

I tried to fix the Windows issue but I couldn't find a solution:

[WARNING] Rule 2: org.apache.maven.plugins.enforcer.EvaluateBeanshell failed with message:
Couldn't evaluate condition: if("quarkus-core-parent".equals("quarkus-build-parent"))
                                           return true;
                                        if(!new File("D:\a\1\s\core" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "quarkus-extension.yaml").exists())
                                            return true;
                                        if("Build parent to bring in required dependencies".contains("Build parent")) 
                                            return false;
                                        return true;

From what I can guess, the issue is that the generated "D:\a\1\s\core" is not a valid Java String, we would need the \ to be escaped.

We would need another way to get the root but BeanShell support is very poorly documented and from the source, I don't see any way to access the project in a Java way. There's no context at all for the interpreter AFAICS.

Maybe we should develop a plain old Java rule but I suspect that it will require some infrastructure?

Well, it's time for my "I told you so" ;).

@maxandersen
Copy link
Member Author

told me so what ? I said several times we would need a custom rule for this quarkus repo specific need. this is something unique for quarkus project layout.

I'll try and make it work on windows; if not we can make a custom rule as indepdent project; shouldn't be a big deal (I hope ;)

@gsmet
Copy link
Member

gsmet commented Apr 22, 2020

I'm closing this as it doesn't work. We would need another approach if we want to pursue this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants