Refresh Gradle Project override .classpath

Hello,
currently I am on the buildship version 2.1.3. Unfortunately, it is still the case that the Classpath file is rewritten in the “Refresh Gradle”. The file looks different than before and can not be used. I have to reset it to the origin after the refresh.
I only call “Refresh Gradle” to download the new versions of the dependent libraries.

before:

after

What doesn’t work? Can you update your example and make it independent of your workstation/windows? That would make it easier to find the problem.

Hello,
I updated the project on gihub. If I run a “gradle refresh”, the file .classpath changes. The order is lost, the JavaContainer is changed and the accessrules are gone. This makes sure that my project is no longer compilable

It is adjusted to match what is defined in your build. That is expected.

The order and access rules are what is defined in your build. You can customize the access rules with the eclipse.classpath.whenMerged {} API.

Hello,
I have adapted my Eclipse Classpath configuration again. Currently I get the lib (properties_zentral, properties_projekt and lib/properties) entries not generated. Do you have an idea?

The other entries are now correct

classpath {
		downloadSources = true
		downloadJavadoc = false

		defaultOutputDir = file('classes/main/java')

		file {
			whenMerged {
				//change DefaultOutputfolder
				def src = entries.find { it.path == 'source' }
				src.output = "classes/main/java"

				def resources = entries.find { it.path == 'src/main/resources' }
				resources.output = "classes/main/resources"

				def testsrc = entries.find { it.path == 'test/java' }
				testsrc.output = "classes/test/java"

				def testres = entries.find { it.path == 'test/resources' }
				testres.output = "classes/test/resources"

				//Add properties entries
				entries += new Library(fileReference(file('properties_zentral')))
				entries += new Library(fileReference(file('properties_projekt')))
				entries += new Library(fileReference(file('lib/properties')))

				//JRE + Access-Rules
				entries.each { source ->
					if (source.kind == 'con' && source.path.startsWith('org.eclipse.jdt.launching.JRE_CONTAINER')) {
						source.path = 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre8'
	                	source.accessRules.add(new AccessRule('2', 'com/sun/net/httpserver/**'))
	                	source.accessRules.add(new AccessRule('1', 'com/sun/**'))
            		}
				}
			}
			containers  'org.eclipse.buildship.core.gradleclasspathcontainer', 'org.eclipse.jdt.junit.JUNIT_CONTAINER/4'
	}
}

Result:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" output="classes/main/java" path="source"/>
	<classpathentry kind="src" output="classes/test/java" path="test/java"/>
	<classpathentry kind="src" output="classes/test/resources" path="test/resources"/>
	<classpathentry kind="src" output="classes/main/resources" path="src/main/resources"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre8">
		<accessrules>
			<accessrule kind="discouraged" pattern="com/sun/net/httpserver/**"/>
			<accessrule kind="nonaccessible" pattern="com/sun/**"/>
		</accessrules>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
	<classpathentry kind="output" path="classes/main/java"/>
</classpath>

The lib entries should be inside the “External and Project Dependencies” container. Can you check whether they are there?

We only need the lib entries for Eclipse. In the Gradle Environment, the entries are not required. properties-central and properties-project are only Eclipse Variables.

I understand that. The entries should be inside the “External and Project Dependencies” container, because you added them in whenMerged. If they are not there, then that would be a bug.

Ok, then I create a ticket. I’ve just seen it worked.