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

[WIP] Issues/63 support maven toolchains plugin #64

Closed
wants to merge 11 commits into from
Closed

[WIP] Issues/63 support maven toolchains plugin #64

wants to merge 11 commits into from

Conversation

exabrial
Copy link

No description provided.

@exabrial exabrial changed the base branch from master to spotbugs June 12, 2018 18:30
@exabrial exabrial changed the title [WIP] Issues/63 support toolchains plugin Issues/63 support maven toolchains plugin Jun 12, 2018
Copy link
Member

@KengoTODA KengoTODA left a comment

Choose a reason for hiding this comment

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

no test code?

@hazendaz
Copy link
Member

@KengoTODA I'm ok with the fact there are no unit tests. There are none currently at all so that doesn't break with the current state and adding them would sort of mean far more on unit tests than the change would imply. The code otherwise looks good and only enables under certain circumstances which I feel are rather limited in real world use. As the large IT set of tests do not break on this, we should be good.

However, @exabrial what might be useful is to write a IT test that covers an example usage of this. Those all run using maven invoker so you should be able to setup one using your expected configuration. I'll hang on this a while before merging in case you can get that together soon. Thanks.

@exabrial
Copy link
Author

How would one assert which jdk is used, especially since antbuilder.java is a static method? (normally i'd mock out that dependency and check to see if the jvm flag is passed)

@hazendaz
Copy link
Member

@exabrial Look at the IT tests and see if you can create one there that runs with toolchains. I did go ahead and release 3.1.5 so others can use that but need to hold on this until concerns raised are addressed :)

@exabrial exabrial changed the title Issues/63 support maven toolchains plugin [WIP] Issues/63 support maven toolchains plugin Jun 21, 2018
@exabrial
Copy link
Author

Attempting an IT... I'm curious what's going to happen on CI

@@ -998,31 +1014,43 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {

def ant = new AntBuilder()

log.info("Fork Value is ${fork}")
Copy link
Member

Choose a reason for hiding this comment

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

please do not remove log that is not related with your fix.

Copy link
Member

Choose a reason for hiding this comment

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

I found that this log is moved to L1041, what is our motivation?

Copy link
Author

Choose a reason for hiding this comment

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

No reason, just made a bit more sense in the log flow I thought

def tc = toolchainManager.getToolchainFromBuildContext("jdk", session);
if (tc != null) {
String foundExecutable = tc.findTool("java");
if (foundExecutable != null) {
Copy link
Member

Choose a reason for hiding this comment

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

We can shorten implementation by safe navigation operator.

Copy link
Author

Choose a reason for hiding this comment

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

thanks. I don't know groovy

Copy link
Author

Choose a reason for hiding this comment

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

So actually, I need to leave the code this way to be consistent with how the other plugins generate their log messages about using Toolchains. I totally understand the safe operator though, and I'm glad you pointed that out.

ant.java(classname: "edu.umd.cs.findbugs.FindBugs2", inputstring: getSpotbugsAuxClasspath(), fork: "${fork}", failonerror: "true", clonevm: "false", timeout: "${timeout}", maxmemory: "${maxHeap}m") {
ant.java([classname: "edu.umd.cs.findbugs.FindBugs2", inputstring: getSpotbugsAuxClasspath(), fork: "${fork}",
jvm: jvmExecutable, failonerror: "true", clonevm: "false", timeout: "${timeout}", maxmemory: "${maxHeap}m",
].findAll{it.value != null}) {
Copy link
Member

Choose a reason for hiding this comment

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

why we need this findAll?

Copy link
Author

Choose a reason for hiding this comment

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

Because the jvmExecutable could possibly be null at this point. This ensures null values are dropped from the map. If you pass null to ant.java you get an NPE.

@exabrial
Copy link
Author

btw I'm in another city at the moment, sorry for the slow progress. I don't have much time to work on this but I'll eventually get it working

@exabrial
Copy link
Author

exabrial commented Jul 2, 2018

@KengoTODA Hey could this build possibly be failing because the lack of a toolchains.xml on the build machine? How can we add this file?

@KengoTODA
Copy link
Member

How about using -s option? It lets specify the path of settings.xml. Then you can commit settings.xml as a part of test case.

@exabrial
Copy link
Author

exabrial commented Jul 3, 2018

@KengoTODA Just so you're absolutely informed what's going on, it's missing a toolchains.xml file, NOT the not settings.xml file you quoted above. The two files have different XSDs.

@exabrial
Copy link
Author

exabrial commented Jul 3, 2018

The toolchains.xml is supposed to be a machine configuration of where the JVMs are physically located on disk. Including those in a commit means that everyone has to set up their machines in the exact same way.
https://maven.apache.org/guides/mini/guide-using-toolchains.html

@KengoTODA
Copy link
Member

How about --global-toolchains ?

@exabrial
Copy link
Author

exabrial commented Jul 14, 2018

I'm going to give up :/ There's not a good way to do Integration Tests without control over the environment. I think the original problem I was facing is less of an issue anyway... (cross compiling a jdk 1.8 on a jdk 1.9 maven vm)

@exabrial exabrial closed this Jul 14, 2018
@hazendaz
Copy link
Member

Tied to #63

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

Successfully merging this pull request may close these issues.

None yet

3 participants