saiddfhi / gwt-maven

Automatically exported from code.google.com/p/gwt-maven
0 stars 0 forks source link

Avoid duplicate entries in run.cmd (maven-googlewebtoolkit2-plugin) #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I'm using the maven-googlewebtoolkit2-plugin for running gwt in hosted
mode. When developing under windows you might run into 'line is too long'
problem, on executing the generated run.cmd. 

I simply modified the ScriptWriterWindows by avoid adding duplicates to the
classpath. Code snippet:

private PrintWriter getPrintWriterWithClasspath(..) {
...
            // collect all added files. so it is possible to avoid
            // duplicate entries
            Set<File> filesAdded = new HashSet<File>();

            StringBuffer cpString = new StringBuffer();

            for (File f : classpath) {
                if (!filesAdded.contains(f)) {
                    cpString.append("\"" + f.getAbsolutePath() + "\";");
                    // break the line at 4000 characters to try to avoid
max size
                    if (cpString.length() > 4000) {
                        writer.println(cpString);
                        cpString = new StringBuffer();
                        writer.print("set CLASSPATH=%CLASSPATH%;");
                    }
                    filesAdded.add(f);
                }
            }
            // add test classes
            for (Iterator it =
mojo.getProject().getTestClasspathElements().iterator(); it.hasNext();) {
                File f = new File(it.next().toString());
                if (!filesAdded.contains(f)) {
                    cpString.append("\"" + f.getAbsolutePath() + "\";");
                    if (cpString.length() > 4000) {
                       writer.println(cpString);
                       cpString = new StringBuffer();
                       writer.print("set CLASSPATH=%CLASSPATH%;");
                   }
                    filesAdded.add(f);
                }
            }
...
}

Class is attached.

Can you give me a feedback to this solution.

Thanks in advance,
best regards,
michi

Original issue reported on code.google.com by michael....@gmail.com on 6 Nov 2008 at 9:08

Attachments:

GoogleCodeExporter commented 9 years ago
I personally don't use Windows, and I break my applications up into separate 
projects
(one for client, one for server, one for model, typically), and then use GWT
inheritance - so I don't have any projects that ever hit the too long issue 
(when I
run the samples and tests in Windows they work fine, and my broken out projects 
work
fine too). 

That said this fix looks reasonable but I don't have any specific feedback 
because I
don't have a "broken" project to try it on. 

Can other Windows people jump in here and try this? 

Original comment by charlie....@gmail.com on 8 Nov 2008 at 11:50

GoogleCodeExporter commented 9 years ago
I also have this problem on Windows. The length of my command line is more than 
8000.

Could you include this fix in the next release?

Original comment by devun...@gmail.com on 13 Nov 2008 at 1:28

GoogleCodeExporter commented 9 years ago
Ok, this one is a valid issue, I see it too in Unix/Linux.  We are adding the 
test
stuff again manually, and that doubles many things. 

THis is fixed in trunk, and will be in next release. 

Original comment by charlie....@gmail.com on 13 Nov 2008 at 4:56

GoogleCodeExporter commented 9 years ago
Also, I don't think all the filesAdded checks are necessary, the classpath 
files set
is already a Set, so it can't contain dupes by definition. I believe the 
problem is
simply the separate test section, which just needs to get removed (the classes 
on the
classpath will be correct coming from BuildClasspathUtil, whether test scope or 
other). 

Original comment by charlie....@gmail.com on 13 Nov 2008 at 4:59

GoogleCodeExporter commented 9 years ago
Have fixes in trunk for this - see issue 176. 

Original comment by charlie....@gmail.com on 19 Nov 2008 at 7:01