'svn diff' shows output that seem like no change - eclipse

A certain 'svn diff' on a '.classpath' file gives me the following output. I don't see any difference between the working copy (+) and the pristine copy (-) (do you?). The problem is I haven't changed these files (i.e. I haven't tried to change the build path of the project) but they seem to be modified during build. I use STS 3.3.0.RELEASE, and no 'svn' plugin. I do use maven plugin for eclipse for build.
It would be nice if they were left untouched. Is there a way, I can ensure this? On the other hand, if my '.classpath' file in question is untouched then why is 'svn diff' giving me this output?
Thanks.
## -1,29 +1,29 ##
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>

The suspicion raised by #JimLewis and others in the comments below the question was indeed true. Saving the output of the said command into a file and doing a cat -v on that file produced the following output:
## -1,34 +1,34 ##
-<?xml version="1.0" encoding="UTF-8"?>^M
-<classpath>^M
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>^M
- <classpathentry kind="src" output="target/classes" path="src/main/java">^M
- <attributes>^M
- <attribute name="optional" value="true"/>^M
- <attribute name="maven.pomderived" value="true"/>^M
- </attributes>^M
- </classpathentry>^M
- <classpathentry kind="src" output="target/test-classes" path="src/test/java">^M
- <attributes>^M
- <attribute name="optional" value="true"/>^M
- <attribute name="maven.pomderived" value="true"/>^M
- </attributes>^M
- </classpathentry>^M
- <classpathentry kind="src" path="src/main/resources"/>^M
- <classpathentry combineaccessrules="false" kind="src" path="/net.holisticlabs.libs.io"/>^M
- <classpathentry combineaccessrules="false" kind="src" path="/net.holisticlabs.libs.config"/>^M
- <classpathentry exported="true" kind="lib" path="jars-not-in-maven-repo/eventful.jar"/>^M
- <classpathentry combineaccessrules="false" kind="src" path="/net.holisticlabs.libs.nlp"/>^M
- <classpathentry combineaccessrules="false" kind="src" path="/net.holisticlabs.libs.attrs"/>^M
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">^M
- <attributes>^M
- <attribute name="maven.pomderived" value="true"/>^M
- </attributes>^M
- </classpathentry>^M
- <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">^M
- <attributes>^M
- <attribute name="maven.pomderived" value="true"/>^M
- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>^M
- </attributes>^M
- </classpathentry>^M
- <classpathentry kind="output" path="target/classes"/>^M
-</classpath>^M
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.holisticlabs.libs.io"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.holisticlabs.libs.config"/>
+ <classpathentry exported="true" kind="lib" path="jars-not-in-maven-repo/eventful.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.holisticlabs.libs.nlp"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.holisticlabs.libs.attrs"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
The original '.classpath' was generated on a Windows machine, that uses CRLF newline character while maven on my unix machine replaced them with LF newline characters. As also was suggested, svn:ignore or 'svn revert' could be used to handle such cases.

Related

Eclipse Gradle Project - Classpath issue - ClassNotFoundException

I am running the below code in a gradle project in Eclipse.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
I am getting ClassNotFoundException for this. The class runs fine in a maven project. Maven's .classpath file looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"
including="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
This is Gradle's .classpath file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main"
path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope"
value="main,test,intTest"/>
</attributes>
</classpathentry>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/
org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/
JavaSE-11/"/>
<classpathentry kind="con"
path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
Is there anything I need to add to build.gradle or make changes to .classpath file to make it work?

eclipse sts gradle multimodule project problem

Using Eclipse STS 4.10 / linux .
I have a multimodule project like :
-rootFolder
-web (web app)
-dataservice (services, domain logic)
-datadef (model,repositories)
web has dataservice as a dependency
build.gradle shows:
dependencies {
compile project(':dataservice')
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
///
}
dataservice has datadef as a dependency
build.gradle shows:
dependencies {
compile project(':datadef')
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
///
}
What I cannot achieve is datadef-1.0.0-SNAPSHOT.jar being included in dataservice-1.0.0-SNAPSHOT.jar file . Both are getting included in web.app though.
Sometimes eclipse "looses" reference on dataservice the datadef project and treat anything from datadef as an error.
Pasting dataservice project .classpath file. It shows the dependency on datadef.
<classpath>
<classpathentry kind="output" path="bin/default"/>
<classpathentry output="bin/main" kind="src" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry output="bin/main" kind="src" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry output="bin/test" kind="src" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="src" path="/datadef">
...```
Thank you.

Class not found..java.lang.ClassNotFoundException:

I have been through many posts but none of those helped! I am getting the following error while running JUnit tests for a test class:
java.lang.ClassNotFoundException: com.company.project.abc.pqr.AbcTest
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:499)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Its running the tests through console but since I want to debug the tests, I need to do that through Eclipse. Can you pleas suggest what can I do?
I tried:
Build Again
Disable Maven Nature and then Enable Maven Nature
Maven Update Project
mvn eclipse:eclipse
mvn eclipse:clean
Added this to .project file
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
EDIT:
Added Run Configuration for the test class:
.classpath file:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes"
path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes"
path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.
launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="GROOVY_DSL_SUPPORT">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
I want to add the packaging in my pom is jar.
jar

Is there a way to make Eclipse Package Explorer show output directory content?

I hate having to switch to the Navigator view just to see what was built. For example, if I want to see if my *.properties files getting moved, etc.
I tried removing all of the Filters... from Package Explorer's dropdown menu, but it is still not displaying the contents of my "target" folder.
Am I missing something?
I attached my .classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
As far as I know, only the Project Explorer view (not Package Explorer) can display output folders.
In that (Project) view, you should see a small down arrow at the top right of the view:
Choose the option Customize View option.
Uncheck the 'Java output folders' option in the filters list.
You would see the same process to see .class files produced by a classic java build.

Why is Eclipse not attaching 3rd party libs source files to a WTP-faceted Gradle project?

The sources are downloaded in the Gradle cache and the classpath-entries for the source files looks ok, but Eclipse does not show the source files for 3rd party libs.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="output" path="bin/main"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry output="bin/test" kind="src" path="src/test/java"/>
<classpathentry output="bin/test" kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container" exported="true"/>
<classpathentry sourcepath="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework/spring-webmvc/3.1.2.RELEASE/source/bc9c347358c5d59998b27e8a13c75106c3d0696/spring-webmvc-3.1.2.RELEASE-sources.jar" kind="lib" path="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework/spring-webmvc/3.1.2.RELEASE/jar/e02f3e5aa91c8caa37b2e9b780229d27e76c0f2e/spring-webmvc-3.1.2.RELEASE.jar" exported="true">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry sourcepath="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework.data/spring-data-jpa/1.2.0.BUILD-SNAPSHOT/source/19e4dedbb956cdc3bb1d34d61a351229b653029a/spring-data-jpa-1.2.0.BUILD-SNAPSHOT-sources.jar" kind="lib" path="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework.data/spring-data-jpa/1.2.0.BUILD-SNAPSHOT/jar/2a3cfc2ea0b2c8d87f32166e16bb56e1f092568b/spring-data-jpa-1.2.0.BUILD-SNAPSHOT.jar" exported="true">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry sourcepath="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework.security/spring-security-web/3.1.2.RELEASE/source/49e8d929d835d4ba4556ba9d138488ecc083a794/spring-security-web-3.1.2.RELEASE-sources.jar" kind="lib" path="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/org.springframework.security/spring-security-web/3.1.2.RELEASE/jar/e43e7683289f08c1e073564a94e6f26298ec4f59/spring-security-web-3.1.2.RELEASE.jar" exported="true">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry sourcepath="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/javax.validation/validation-api/1.0.0.GA/source/7a561191db2203550fbfa40d534d4997624cd369/validation-api-1.0.0.GA-sources.jar" kind="lib" path="D:/Users/SSchneider/.gradle/caches/artifacts-14/filestore/javax.validation/validation-api/1.0.0.GA/jar/b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e/validation-api-1.0.0.GA.jar" exported="true">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
</classpath>
That's a weird behavior in Eclipse with the generated .classpath-file. Just put the 'Web App Libraries' entry at the bottom of your classpath file (-> Java Build Path -> Order and Export).
The best solution is to enhance your gradle.build file (then you don't need to reorder your build path each time you generate the classpath file via gradle):
...
eclipse.classpath.file {
// Classpath entry for Eclipse which changes the order of classpathentries; otherwise no sources for 3rd party jars are shown
withXml { xml ->
def node = xml.asNode()
node.remove( node.find { it.#path == 'org.eclipse.jst.j2ee.internal.web.container' } )
node.appendNode( 'classpathentry', [ kind: 'con', path: 'org.eclipse.jst.j2ee.internal.web.container', exported: 'true'])
}
}