Maven 1.x Application Generation Plugin

Allow project to be generated somewhere else ${basedir}

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.2
  • Fix Version/s: 2.3
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

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.

Activity

Hide
Felipe Leme added a comment -

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

Show
Felipe Leme added a comment - Fixed. PS: I added a test case, although the test case interactes with the user (which is bad .
Hide
Arnaud Heritier added a comment -

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.

Show
Arnaud Heritier added a comment - 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.
Hide
Felipe Leme added a comment -

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

Show
Felipe Leme added a comment - 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
Hide
Felipe Leme added a comment -

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

Show
Felipe Leme added a comment - 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
Hide
Arnaud Heritier added a comment -

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.

Show
Arnaud Heritier added a comment - 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.
Hide
Felipe Leme added a comment -

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

Show
Felipe Leme added a comment - 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

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
30m
Original Estimate - 30 minutes
Remaining:
30m
Remaining Estimate - 30 minutes
Logged:
Not Specified
Time Spent - Not Specified