[ 
https://issues.apache.org/jira/browse/NETBEANS-3575?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tomáš Procházka closed NETBEANS-3575.
-------------------------------------

> Fixed ordering of j2ee.platform.classpath entires
> -------------------------------------------------
>
>                 Key: NETBEANS-3575
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-3575
>             Project: NetBeans
>          Issue Type: Improvement
>            Reporter: András Sik
>            Assignee: András Sik
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 12.0
>
>          Time Spent: 4h 40m
>  Remaining Estimate: 0h
>
> According to my experience *j2ee.platform.classpath* entries are "randomly" 
> ordered in the corresponding project.properties files (where applicable). It 
> would be much better, if the ordering would be fixed (eg. alphabetical 
> regarding the (absolute) path of the entries), so it would not cause constant 
> problems for various version management systems. (They tend to mark this line 
> as changed, since the order may vary, and thus may cause unnecessary 
> conflicts.)
> This has been bugging me (and I bet also others) for quite a while now, to an 
> extent to try to fix it on my own. I might have found a solution which seems 
> to work for me. In doing so, I have modified the NetBeans source code, but 
> now I'm unsure of what to do, or if my solution is correct. Given that I've 
> never contributes to the Apache community I'd decided it might be the best if 
> I opened a ticket abut it here.
> My modification is really simple, and all it does is order the classpath 
> entries in an ascending order, based on the absolute pathname of the 
> corresponding files. This is all done in 
> org.netbeans.modules.j2ee.common.ClassPathUtil.java, where 
> getJ2eePlatformClasspathEntries is defined. Of course this could be polished, 
> but I'd like to know first if such modification would be allowed at all?
> Here is the quick fix, I was referring to: (original source if based on TAG 
> 11.2)
> {code:java}
> public static File[] getJ2eePlatformClasspathEntries(@NullAllowed Project 
> project, @NullAllowed J2eePlatform j2eePlatform) {
>     if (project != null) {
>         J2eeModuleProvider j2eeModuleProvider = 
> project.getLookup().lookup(J2eeModuleProvider.class);
>         if (j2eeModuleProvider != null) {
>             J2eePlatform j2eePlatformLocal = j2eePlatform != null ? 
> j2eePlatform : 
> Deployment.getDefault().getJ2eePlatform(j2eeModuleProvider.getServerInstanceID());
>             if (j2eePlatformLocal != null) {
>                 try {
>                     File[] files = 
> j2eePlatformLocal.getClasspathEntries(j2eeModuleProvider.getConfigSupport().getLibraries());
>                     sortClassPathEntries(files);
>                     return files;
>                     //return 
> j2eePlatformLocal.getClasspathEntries(j2eeModuleProvider.getConfigSupport().getLibraries());
>                 } catch (ConfigurationException ex) {
>                     LOGGER.log(Level.FINE, null, ex);
>                     File[] files = j2eePlatformLocal.getClasspathEntries();
>                     sortClassPathEntries(files);
>                     return files;
>                     //return j2eePlatformLocal.getClasspathEntries();
>                 }
>             }
>         }
>     }
>     if (j2eePlatform != null) {
>         File[] files = j2eePlatform.getClasspathEntries();
>         sortClassPathEntries(files);
>         return files;
>         //return j2eePlatform.getClasspathEntries();
>     }
>     return new File[] {};
> }
> private static void sortClassPathEntries(File[] files) {
>     Arrays.sort(files, new Comparator < File > () {
>         @Override
>         public int compare(File f1, File f2) {
>             return f1.getAbsolutePath().compareTo(f2.getAbsolutePath());
>         }
>     });
> }{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to