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

525880: add test for preserving access rules #54

Merged
merged 1 commit into from Nov 23, 2017
Merged

525880: add test for preserving access rules #54

merged 1 commit into from Nov 23, 2017

Conversation

greensopinion
Copy link
Contributor

Add test to verify that access rules are preserved on the Maven
classpath container when a Java project is updated.

Gerrit-Url: https://git.eclipse.org/r/#/c/106604/
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=525880
Signed-off-by: David Green david.green@tasktop.com

}

private void assertContainersHaveAccessRules(IJavaProject javaProject) throws JavaModelException {
List<IClasspathEntry> containerEntries = Arrays.asList(javaProject.getRawClasspath()).stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

Stream.of(javaProject.getRawClasspath()) is shorter :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right! Are you asking me to change this? If so, are there other changes you're looking for too, or is this it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't tested the changes yet, but looking at the test, it looks like you're testing the maven container retains the access rules, globally.
I think it'd better to be more explicit, test access rules on a particular dependency. Eg. add junit and something else, add access rules to junit, check only junit has access rules after update.

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 think I'm missing something.

This change is about ensuring that access rules added to the M2E container are preserved. E.g.


	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
		<accessrules>
			<accessrule kind="discouraged" pattern="**/internal/**"/>
		</accessrules>
	</classpathentry>

So this test is testing only the functionality that was added.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok my bad, as I said I haven't checked yet. But wouldn't it be better to also have a more fine grained control over each 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.

Perhaps, but that is not our use-case.

Out of interest I've tried adding per-dependency access rules to dependencies in the M2E container in the Eclipse UI. The UI appears to work, but no changes appear in the .classpath file, and when I re-open the "configure build path" dialog, the access rules are gone. So I'm wondering if such a thing is even possible?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it's possible this would require more complex changes to serialize the state of the maven classpath container (those changes would not be stored in .classpath, but in another file under .metadata). Let's put that one on the back burner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, sounds good.

@fbricon
Copy link
Contributor

fbricon commented Nov 15, 2017

Huh why does github say that I'm the committer, given that I haven't merged it yet??

@greensopinion
Copy link
Contributor Author

I'm not sure... looks like I might have messed up the original commit: https://github.com/greensopinion/m2e-core-tests/commit/9388ed2130d4a025685022a37360e9cd97b571d4

Add test to verify that access rules are preserved on the Maven
classpath container when a Java project is updated.

Gerrit-Url: https://git.eclipse.org/r/#/c/106604/
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=525880
Signed-off-by: David Green <david.green@tasktop.com>
@greensopinion
Copy link
Contributor Author

OK, I think I've fixed the committer misattribution

@fbricon fbricon merged commit 11205a8 into tesla:master Nov 23, 2017
@greensopinion greensopinion deleted the 525880 branch November 23, 2017 16:57
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

2 participants