Issue Details (XML | Word | Printable)

Key: MPGENAPP-24
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Felipe Leme
Reporter: Felipe Leme
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Maven 1.x Application Generation Plugin

Allow project to be generated somewhere else ${basedir}

Created: 24/Oct/05 01:22 PM   Updated: 25/Oct/05 06:17 PM   Resolved: 24/Oct/05 02:02 PM
Return to search
Component/s: None
Affects Version/s: 2.2
Fix Version/s: 2.3

Time Tracking:
Original Estimate: 30 minutes
Original Estimate - 30 minutes
Remaining Estimate: 30 minutes
Remaining Estimate - 30 minutes
Time Spent: Not Specified
Time Spent - Not Specified


 Description  « Hide

When you run genapp, it creates the new project in the current directory. I see at least one situation (which is why I'm creating this issue) where that is not desired: when creating test cases for this plugin!

So, I will create a maven.genapp.basedir property to fix this issue.



Felipe Leme added a comment - 24/Oct/05 02:02 PM

Fixed.
PS: I added a test case, although the test case interactes with the user (which is bad .


Felipe Leme made changes - 24/Oct/05 02:02 PM
Field Original Value New Value
Resolution Fixed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]
Arnaud Heritier added a comment - 24/Oct/05 03:10 PM

You read in my mind Felipe.
Some weeks ago I wanted to add tests for the plugin and I found I couldn't do it due to this limitation !!
Thanks a lot to did it.


Felipe Leme added a comment - 24/Oct/05 08:59 PM

Hi Arnauld,

Well, at least after months of inactivity I contributed with something useful

Now we just need to figure it out an elegant way to bypass those <i:ask> questions...

– Felipe


Felipe Leme added a comment - 25/Oct/05 03:37 PM

Arnauld,

I have createad a class that sets the System.in to always return enter:

package org.apache.maven.genapp.testing;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

public class NewlinerInputStream extends BufferedInputStream {

private static final InputStream SYSTEM_IN = System.in;
private static final NewlinerInputStream THE_INSTANCE = new NewlinerInputStream(SYSTEM_IN);

public static void replaceSystemIn() { System.setIn( THE_INSTANCE ); }

public NewlinerInputStream(InputStream in) { super(in); }

public synchronized int read(byte[] b, int off, int len) throws IOException { b[0] = '\n'; return 1; }

}

And then on maven.xml I used:

<goal name="test-genapp" prereqs="clean,java:compile">
<j:invokeStatic className="org.apache.maven.genapp.testing.NewlinerInputStream" method="replaceSystemIn"/>
<attainGoal name="genapp"/>
</goal>

But I got a ClassNotFoundException:

BUILD FAILED
File...... e:\cvs\maven\svn\plugins\trunk\genapp\src\plugin-test\basedirTest\mav
en.xml
Element... j:invokeStatic
Line...... 30
Column.... 110
org.apache.maven.genapp.testing.NewlinerInputStream
Total time: 2 seconds
Finished at: Tue Oct 25 18:31:39 BRST 2005

Do you know how should I set Jelly to use that class (which is under src/main on the plugin - I have also set the <build> on the testcase's POM to that value)?

Thks,

– Felipe


Arnaud Heritier added a comment - 25/Oct/05 05:29 PM

Hi Felipe.

Did you see that you could bypass the <i:ask> with something like :
maven -Dtemplate=default -Dmaven.genapp.template.id=myId -Dmaven.genapp.template.name="My Name" -Dmaven.genapp.template.package=org.apache.mypackage genapp
For the problem of class not found, I don't know what happens.
Did you take a look at the xdoc plugin ? There are some invokeStatic . For example :
<j:invokeStatic className="org.apache.maven.xdoc.util.LocaleUtil" method="codeToLocale" var="defaultLocale">
<j:arg value="${maven.xdoc.locale.default}" type="java.lang.String"/>
</j:invokeStatic>
I don't understand why it doesn't work for you. It's very similar.


Felipe Leme added a comment - 25/Oct/05 06:17 PM

Hi again,

I tried to set the properties to skip the prompt, but it didn't work, I mean, not all the questions were skipped; I will try again anyway.

Regarding the invokeStatic, I will take a look on the xdocs plugin. What I know works is to access a class that is included in a dependency; if that's the case, I could move that class to the main plugin (in fact, doing so would allow to reuse it for other genapp test cases).

– Felipe