-
Notifications
You must be signed in to change notification settings - Fork 408
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
JAR files are not refreshed after they are updated #1002
Merged
+144
−11
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
import java.util.stream.Stream; | ||
|
||
import org.codehaus.plexus.util.StringUtils; | ||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IFolder; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IProjectDescription; | ||
|
@@ -589,6 +590,16 @@ public List<FileSystemWatcher> registerWatchers() { | |
|
||
} | ||
} | ||
if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { | ||
IPath path = entry.getPath(); | ||
IFile resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path); | ||
if (resource != null && !resource.isDerived()) { | ||
IPath location = resource.getLocation(); | ||
if (location != null && !isContainedIn(location, sources)) { | ||
sources.add(location); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. problem is you're later appending /** to the jar extension, which seems to cause some issues on my mac |
||
} | ||
} | ||
} | ||
} | ||
if (!ProjectUtils.isVisibleProject(project)) { | ||
//watch lib folder for invisible projects | ||
|
7 changes: 7 additions & 0 deletions
7
org.eclipse.jdt.ls.tests/projects/eclipse/updatejar/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="lib" path="lib/foo.jar"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
17 changes: 17 additions & 0 deletions
17
org.eclipse.jdt.ls.tests/projects/eclipse/updatejar/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>updatejar</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
org.eclipse.jdt.ls.tests/projects/eclipse/updatejar/src/Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import foo.bar; | ||
|
||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
int sum = bar.add(1, 2, 3); | ||
System.out.println(sum); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...e.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/managers/EclipseBuildSupportTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.ls.core.internal.managers; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.eclipse.core.resources.IMarker; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.jdt.ls.core.internal.ResourceUtils; | ||
import org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.CHANGE_TYPE; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
/** | ||
* @author snjeza | ||
* | ||
*/ | ||
@RunWith(MockitoJUnitRunner.class) | ||
public class EclipseBuildSupportTest extends AbstractProjectsManagerBasedTest { | ||
|
||
@Test | ||
public void testUpdateJar() throws Exception { | ||
importProjects("eclipse/updatejar"); | ||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("updatejar"); | ||
assertIsJavaProject(project); | ||
List<IMarker> errors = ResourceUtils.getErrorMarkers(project); | ||
assertEquals("Unexpected errors " + ResourceUtils.toString(errors), 2, errors.size()); | ||
File projectFile = project.getLocation().toFile(); | ||
File validFooJar = new File(projectFile, "foo.jar"); | ||
File destLib = new File(projectFile, "lib"); | ||
FileUtils.copyFileToDirectory(validFooJar, destLib); | ||
File newJar = new File(destLib, "foo.jar"); | ||
projectsManager.fileChanged(newJar.toPath().toUri().toString(), CHANGE_TYPE.CREATED); | ||
waitForBackgroundJobs(); | ||
errors = ResourceUtils.getErrorMarkers(project); | ||
assertEquals("Unexpected errors " + ResourceUtils.toString(errors), 0, errors.size()); | ||
|
||
} | ||
|
||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the target classpathEntry is found, add
break
to exit ealier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.