Lines 61-66
Link Here
|
61 |
import java.util.HashSet; |
61 |
import java.util.HashSet; |
62 |
import java.util.Iterator; |
62 |
import java.util.Iterator; |
63 |
import java.util.List; |
63 |
import java.util.List; |
|
|
64 |
import java.util.Properties; |
64 |
import java.util.Set; |
65 |
import java.util.Set; |
65 |
import java.util.concurrent.atomic.AtomicBoolean; |
66 |
import java.util.concurrent.atomic.AtomicBoolean; |
66 |
import java.util.concurrent.atomic.AtomicReference; |
67 |
import java.util.concurrent.atomic.AtomicReference; |
Lines 81-86
Link Here
|
81 |
import org.apache.maven.model.Dependency; |
82 |
import org.apache.maven.model.Dependency; |
82 |
import org.apache.maven.model.DependencyManagement; |
83 |
import org.apache.maven.model.DependencyManagement; |
83 |
import org.apache.maven.model.Profile; |
84 |
import org.apache.maven.model.Profile; |
|
|
85 |
import org.apache.maven.project.MavenProject; |
84 |
import org.codehaus.plexus.util.FileUtils; |
86 |
import org.codehaus.plexus.util.FileUtils; |
85 |
import org.netbeans.api.annotations.common.CheckForNull; |
87 |
import org.netbeans.api.annotations.common.CheckForNull; |
86 |
import org.netbeans.api.annotations.common.NonNull; |
88 |
import org.netbeans.api.annotations.common.NonNull; |
Lines 156-161
Link Here
|
156 |
private static final @StaticResource String TRANSITIVE_MAVEN_ICON = "org/netbeans/modules/maven/TransitiveMaven2Icon.png"; |
158 |
private static final @StaticResource String TRANSITIVE_MAVEN_ICON = "org/netbeans/modules/maven/TransitiveMaven2Icon.png"; |
157 |
|
159 |
|
158 |
private Artifact art; |
160 |
private Artifact art; |
|
|
161 |
private boolean potentialRelocation; |
159 |
private NbMavenProjectImpl project; |
162 |
private NbMavenProjectImpl project; |
160 |
private boolean longLiving; |
163 |
private boolean longLiving; |
161 |
private PropertyChangeListener listener; |
164 |
private PropertyChangeListener listener; |
Lines 206-211
Link Here
|
206 |
public DependencyNode(NbMavenProjectImpl project, Artifact art, FileObject fo, boolean isLongLiving) { |
209 |
public DependencyNode(NbMavenProjectImpl project, Artifact art, FileObject fo, boolean isLongLiving) { |
207 |
this(project, art, fo, isLongLiving, createNodeDelegate(art, fo, isLongLiving)); |
210 |
this(project, art, fo, isLongLiving, createNodeDelegate(art, fo, isLongLiving)); |
208 |
} |
211 |
} |
|
|
212 |
|
213 |
/** |
214 |
* Return a string with applied maven properties. |
215 |
*/ |
216 |
private static String applyProps(String string, MavenProject p) { |
217 |
Properties props = p.getProperties(); |
218 |
// add only the needed project properties |
219 |
props.setProperty("project.groupId", p.getGroupId()); |
220 |
props.setProperty("project.version", p.getVersion()); |
221 |
// resolve properties |
222 |
for (Object prop : props.keySet()) { |
223 |
string = string.replaceAll("\\$\\{" + prop.toString() + "\\}", props.getProperty((String)prop)); |
224 |
} |
225 |
return string; |
226 |
} |
227 |
/** |
228 |
* return true if artifact is relocated |
229 |
*/ |
230 |
private static boolean checkRelocation(Artifact art, @NonNull MavenProject p) { |
231 |
boolean tmp = true; |
232 |
|
233 |
for (Dependency dep : p.getOriginalModel().getDependencies()) { |
234 |
if (art.getArtifactId().equals(applyProps(dep.getArtifactId(), p)) |
235 |
&& (art.getGroupId().equals(applyProps(dep.getGroupId(), p))) |
236 |
&& (art.getVersion().equals(applyProps(dep.getVersion(), p)))) { |
237 |
// found one dep matching artifact it's not relocated |
238 |
tmp = false; |
239 |
} |
240 |
} |
241 |
return tmp; |
242 |
} |
209 |
|
243 |
|
210 |
private DependencyNode( |
244 |
private DependencyNode( |
211 |
NbMavenProjectImpl project, |
245 |
NbMavenProjectImpl project, |
Lines 216-221
Link Here
|
216 |
super(createChildren(nodeDelegate), createLookup(project, art, nodeDelegate)); |
250 |
super(createChildren(nodeDelegate), createLookup(project, art, nodeDelegate)); |
217 |
this.project = project; |
251 |
this.project = project; |
218 |
this.art = art; |
252 |
this.art = art; |
|
|
253 |
this.potentialRelocation = checkRelocation(art, project.getOriginalMavenProject()); |
219 |
this.fileObject = new AtomicReference<FileObject>(fo); |
254 |
this.fileObject = new AtomicReference<FileObject>(fo); |
220 |
longLiving = isLongLiving; |
255 |
longLiving = isLongLiving; |
221 |
if (longLiving) { |
256 |
if (longLiving) { |
Lines 328-333
Link Here
|
328 |
String[] id = trail.get(i).split(":"); // g:a:t[:c]:v |
363 |
String[] id = trail.get(i).split(":"); // g:a:t[:c]:v |
329 |
buf.append("<i>").append(DESC_via()).append("</i> ").append(id[1]).append("<br>"); |
364 |
buf.append("<i>").append(DESC_via()).append("</i> ").append(id[1]).append("<br>"); |
330 |
} |
365 |
} |
|
|
366 |
if (potentialRelocation && !isTransitive()) { |
367 |
buf.append("This artifact seems relocated. You may want to update pom."); |
368 |
} |
331 |
// it seems that with ending </html> tag the icon descriptions are not added. |
369 |
// it seems that with ending </html> tag the icon descriptions are not added. |
332 |
// buf.append("</html>");//NOI18N |
370 |
// buf.append("</html>");//NOI18N |
333 |
return buf.toString(); |
371 |
return buf.toString(); |
Lines 365-370
Link Here
|
365 |
sourceExists.set(getSourceFile().exists()); |
403 |
sourceExists.set(getSourceFile().exists()); |
366 |
javadocExists.set(getJavadocFile().exists()); |
404 |
javadocExists.set(getJavadocFile().exists()); |
367 |
fileObject.set(fo); |
405 |
fileObject.set(fo); |
|
|
406 |
if (project != null) { |
407 |
checkRelocation(art, this.project.getOriginalMavenProject()); |
408 |
} |
368 |
setDisplayName(createName(longLiving)); |
409 |
setDisplayName(createName(longLiving)); |
369 |
setIconBase(longLiving); |
410 |
setIconBase(longLiving); |
370 |
fireIconChange(); |
411 |
fireIconChange(); |
Lines 395-400
Link Here
|
395 |
if (!art.getArtifactHandler().isAddedToClasspath() && !Artifact.SCOPE_COMPILE.equals(art.getScope())) { |
436 |
if (!art.getArtifactHandler().isAddedToClasspath() && !Artifact.SCOPE_COMPILE.equals(art.getScope())) { |
396 |
n.append(" <i>[").append(art.getScope()).append("]</i>"); |
437 |
n.append(" <i>[").append(art.getScope()).append("]</i>"); |
397 |
} |
438 |
} |
|
|
439 |
if (potentialRelocation && !isTransitive()) { |
440 |
n.append("<font color='#FFA500'>[R]</font>"); |
441 |
} |
398 |
n.append("</html>"); |
442 |
n.append("</html>"); |
399 |
return n.toString(); |
443 |
return n.toString(); |
400 |
} |
444 |
} |