Modifying classpath takes previous attributes into account #261
Modifying classpath takes previous attributes into account #261
Conversation
As i previously said, no tests, since there is nothing to test. From my investigation it seems any change to the classpath by the user is not reflected in m2e. For example if i change the |
@WonderCsabo That use-case seems easy to test: just modify a POM and simulate a "Maven -> Update project" command via the m2e API. Is it more complicated than this? What leads you to believe this is a problem with the upstream m2e project? |
Unfortunately m2e has indeed some problems with classpath attributes. Non-pom-derived attributes are just dropped when updating a maven project. But, your idea about testing is good. Now i just have to find a modification in the POM, which adds an additional pom derived attribute to a classpath entry. But i am not what POM config is reflect in the Eclipse classpath in this way, if there is a config at all. |
@WonderCsabo If this is an issue with the upstream project, I would suggest we close this ticket in favour of the one currently open against m2e. |
Nope, because m2e still can add attributes from the pom we would drop. The idea of this change: inherit the classpath from m2e and only modify the necessary things. |
For example: i have to set the output foldet to bin. |
I added a test which fails with the old implementation and passes with the new. m2e reads include patterns from the POM and adds them to the classpath entry. When we modify the output folder of the entry, we should not touch these includes, but with the old implementation, we totally drop them. |
I think m2e does not add any properties to the classpath container, at least what i found when i investigated m2e codebase. So there is no property we could test against, and my change about classpath containers is a "just in case" thing. I think i fully covered the case with the source entry. Also please note that my comment from February is not true, and i corrected myself a week ago. Also |
Refactorings un-related to the main change like this should be kept in separate commits and clearly marked as refactorings to avoid confusion.
This is confusing: so we do not drop the |
I'll split the commits, then.
These classpath attributes are added by m2e. m2e reads inclusions, encodings, etc from the POM, and adds these properties to the classpath. And with the previous implementation, we dropped almost all properties, because we created a completely new object with default values. My implementation just reuses the entry which was created by m2e, so nothing is dropped by us what was added by m2e.
classpath.addSourceEntry(entry.getPath(), project.getFullPath().append(path), true); If you think, i can add another test which tests |
I'm still really confused: you say:
But then you say:
These are all the attributes you listed as being dropped? What other attributes are being dropped? These statements appear to contradict each other.
I do not think these additional tests would be "dumb": if previous implementations break behaviour by dropping specific attributes I need to see proof that this is no longer happening. This also prevents future changes to the code introducing regressions. |
These are not contradictions. Yeah,
if(generated) {
descriptor.setClasspathAttribute(IClasspathAttribute.OPTIONAL, "true"); //$NON-NLS-1$
}
|
So we are retaining the |
ee76d8f
to
384ce6d
Compare
Updated. |
0189a69
to
c7d89b5
Compare
Thanks, I'll try and re-review soon. Also, the CI build is still reporting a failure. |
The failures in the CI build are totally unrelated. Unforgettably our Travis build became unstable some time ago. I found out that the Maven Dependency Container also has |
These need to go green before a PR can be merged. Please let me know when they do. |
c7d89b5
to
453315e
Compare
The CI build is done. You have to restart the jobs to make it green, or merge it without passing. |
The Travis build is ridiculously unstable. I just started it my fork again for the 4th time, and Indigo and Juno are still failing. I think we should not wait for passing. |
I appreciate its annoying nut I think, rather than ignore these results, we should focus on improving the stability of the build. If we start ignoring build failures we may break something for older builds. |
Actually, I think the issue is not with the tests or how we are building, but with the Travis CI system in general. It keeps getting error code 137s which are system errors. None of those issues show up locally in my Jenkins CI build of the various target platforms. |
I also suspect that something changed about Travis, and this is not our fault. (I already wrote this in another issue). These issues started to appear some time ago, and they were never present before. @kingargyle is there any way to get the real error behind code 137? I added all the debug flags in a test Travis build and unfortunately it did not reveal more info. |
It is basically the OS killing the process. Some information here: http://stackoverflow.com/questions/18524574/java-program-terminate-with-java-result-137 |
Then it can be the OOM problem which was logged in one case. |
If we are getting OOM issues, those we can handle by increasing the heapsize or permgen that is passed into the tycho-surefire-tests as part of the arguments parameter. |
The current argline is:
How should we modify this? It is a shame, but i am quiet noob at these parameters... PS: maybe we should continue the discussion in the referenced thread. |
Not sure we need to have 1024m of PermSize. Usually 256m is more than enough. Also, for the Xmx 512m should be enough. I would start -Xms at 256m as well. Part of the problem is that we may be requesting more memory than the machine that the job runs on has available. |
I learned that the machine has 3GB of memory, but i do not know how much free memory we have at build. I added a |
It seems these settings did not help. I really hate this. BTW, free -m output this:
|
CI fixed (#274) so you might want to rebase this so it goes green. |
453315e
to
1823285
Compare
There were the following issues with your Pull Request
Guidelines are available at https://github.com/rgladwell/m2e-android This message was auto-generated by https://gitcop.com |
1823285
to
932460d
Compare
There were the following issues with your Pull Request
Guidelines are available at https://github.com/rgladwell/m2e-android/blob/master/CONTRIBUTING.md This message was auto-generated by https://gitcop.com |
When the output location of a sourcepath entry was modified by m2e-android, it created a whole new classpath entry with default values, so properties added to the old entry by m2e was dropped. This new implementation just modifies the old entry object, so all attributes added by m2e are retained. Also when the Maven Container was set as exported, the attributes of the old entry was not copied into the new entry. Now all attributes are copied to the new entry. https://github.com/rgladwell/m2e-android/issues/182
This test checks that we do not drop the attributes after project configuration.
932460d
to
fd1b7c8
Compare
Great PR, thanks for this. |
…utes Modifying classpath takes previous attributes into account
Thanks for the review and feedback! |
This little PR is loosely related to #182. It is not a good practice to create new entries, this change takes previous attributes into account. Also i refactored the code so i think it is a little bit cleaner now. I did not add any tests, since there is nothing to test in this PR.