You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Fred Bricon (JIRA)" <ji...@codehaus.org> on 2011/04/30 21:05:22 UTC

[jira] Created: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
---------------------------------------------------------------------------------------------

                 Key: ARCHETYPE-371
                 URL: http://jira.codehaus.org/browse/ARCHETYPE-371
             Project: Maven Archetype
          Issue Type: New Feature
          Components: Plugin
    Affects Versions: 2.0
         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /usr/local/maven
Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
Default locale: fr_FR, platform encoding: UTF-8
OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
            Reporter: Fred Bricon


Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.

So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.

What do you think?


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Herve Boutemy (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272601#comment-272601 ] 

Herve Boutemy commented on ARCHETYPE-371:
-----------------------------------------

seems easy and efficient

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272356#comment-272356 ] 

Olivier Lamy commented on ARCHETYPE-371:
----------------------------------------

an idea I have is to have the possibility of more "complicated" search query
{code}
// g for groupId a for artifactId
-Dfilter=g:maven,a:plugin
// default on artifactId
-Dfilter=plugin
{code}
WDYT ?


> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272359#comment-272359 ] 

Olivier Lamy commented on ARCHETYPE-371:
----------------------------------------

first simple impl in [rev 1143127|http://svn.apache.org/viewvc?rev=1143127&view=rev]
I leave the issue open until :
* filtering with g: and a:
* provide test.

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272358#comment-272358 ] 

Olivier Lamy commented on ARCHETYPE-371:
----------------------------------------

no worries I will push the first simple implementation 

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Fred Bricon (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272357#comment-272357 ] 

Fred Bricon commented on ARCHETYPE-371:
---------------------------------------

Could be useful indeed. 
I'm sorry I didn't follow up on this issue so far, I've been swamped IRL :-)
I haven't lost hope of being able to provide a patch yet :-)

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272749#comment-272749 ] 

Olivier Lamy commented on ARCHETYPE-371:
----------------------------------------

both supported in r1144639.
Leave it open until I have review documentation.

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Fred Bricon (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=265316#action_265316 ] 

Fred Bricon commented on ARCHETYPE-371:
---------------------------------------

After a bit of hacking, I managed to get the following results :

{noformat}
[fbricon@fbricon Temp]$ mvn org.apache.maven.plugins:maven-archetype-plugin:2.1-SNAPSHOT:generate -Dfilter=jee
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: remote -> ear-jee5 (-)
2: remote -> ejb-jee5 (-)
3: remote -> webapp-jee5 (-)
4: remote -> jee6-basic-archetype (-)
5: remote -> jee6-minimal-archetype (-)
6: remote -> jee6-sandbox-archetype (-)
7: remote -> jee6-sandbox-demo-archetype (-)
8: remote -> jee6-servlet-basic-archetype (-)
9: remote -> jee6-servlet-demo-archetype (-)
10: remote -> jee6-servlet-minimal-archetype (-)
11: remote -> jee6-servlet-sandbox-archetype (-)
12: remote -> imixs-workflow-jee-archetype (Imixs Workflow JEE Archetype provides a JEE Sample Application)
13: remote -> weld-jsf-jee (Weld archetype for creating a Java EE 6 application using JSF 2.0, CDI 1.0, EJB 3.1 and JPA 2.0 (persistence unit included))
14: remote -> weld-jsf-jee-minimal (Weld archetype for creating a minimal Java EE 6 application using JSF 2.0, CDI 1.0 and EJB 3.1 (persistence unit not included))
Choose a number: : 13
Downloading: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.jar
Downloaded: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.jar (138 KB at 121.2 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.pom
Downloaded: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.pom (2 KB at 1.9 KB/sec)
Define value for property 'groupId': : foo.bar
Define value for property 'artifactId': : weldy
[INFO] Using property: version = 1.0.0-SNAPSHOT
Define value for property 'package':  foo.bar: : 
Confirm properties configuration:
groupId: foo.bar
artifactId: weldy
version: 1.0.0-SNAPSHOT
package: foo.bar
 Y: : 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31.635s
[INFO] Finished at: Sun May 01 00:09:10 CEST 2011
[INFO] Final Memory: 6M/245M
[INFO] ------------------------------------------------------------------------

{noformat}

Basically, the code in org.apache.maven.archetype.ui.DefaultArchetypeSelector looks like :

{noformat}
    public void selectArchetype( ArchetypeGenerationRequest request, Boolean interactiveMode, String catalogs )
        throws ArchetypeNotDefined, UnknownArchetype, UnknownGroup, IOException, PrompterException,
        ArchetypeSelectionFailure
    {
        ...
        Map<String, List<Archetype>> archetypes = getFilteredArchetypes(getArchetypesByCatalog( catalogs ), 
                                                                                                request.getFilter() );
        ...
{noformat}

{noformat}
    private Map<String, List<Archetype>> getFilteredArchetypes(	Map<String, List<Archetype>> archetypesByCatalog, 
    															final String filter) {
    	
    	if (StringUtils.isNotEmpty(filter) && !archetypesByCatalog.isEmpty()) 
    	{
        	for (Map.Entry<String, List<Archetype>> entry : archetypesByCatalog.entrySet()) 
        	{
            	CollectionUtils.filter(entry.getValue(), new Predicate() 
            	{
					public boolean evaluate(Object archetype) 
					{
						return ((Archetype) archetype).getArtifactId().contains(filter);
					}
				});
        	}
    	}
		return archetypesByCatalog;
	}
{noformat}

This implementation has a minimum impact on the code. However, doing the actual filtering would probably be more appropriate directly in the ArchetypeCatalog class, but that would require more code change. It's debatable.

If this implementation suits you, I can add some test cases and attach a patch here. You tell me :-)



> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: http://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Herve Boutemy (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Herve Boutemy updated ARCHETYPE-371:
------------------------------------

    Fix Version/s: 2.1

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: http://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Herve Boutemy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272566#comment-272566 ] 

Olivier Lamy commented on ARCHETYPE-371:
----------------------------------------

nice idea to not having to know this magic -Dfiler= :-).
BTW the first goal was more to remove the *HUGE* list of archetype.
We can certainly do both :-).
Agree on the format ? :  groupId:artifactId ? 
Samples :
* org.apache:     -> display all archetypes which contains org.apache in groupId
* :jee or jee     -> display all archetypes which contains jee in artifactId
* org.apache:jee  -> display all archetypes which contains org.apache in groupId *AND* jee in artifactId

makes sense ?

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Herve Boutemy (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272513#comment-272513 ] 

Herve Boutemy commented on ARCHETYPE-371:
-----------------------------------------

Idea: at the prompt, propose "Choose a number or filter:"
if data entered is not a number, then assume it's a filter and display newly filtered archetypes
then you don't really need to know -Dfilter, you can interactively test filters

I didn't if it is really hard to implement or not...

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Issue Comment Edited: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Fred Bricon (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=265316#action_265316 ] 

Fred Bricon edited comment on ARCHETYPE-371 at 4/30/11 5:48 PM:
----------------------------------------------------------------

After a bit of hacking, I managed to get the following results :

{noformat}
[fbricon@fbricon Temp]$ mvn org.apache.maven.plugins:maven-archetype-plugin:2.1-SNAPSHOT:generate -Dfilter=jee
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: remote -> ear-jee5 (-)
2: remote -> ejb-jee5 (-)
3: remote -> webapp-jee5 (-)
4: remote -> jee6-basic-archetype (-)
5: remote -> jee6-minimal-archetype (-)
6: remote -> jee6-sandbox-archetype (-)
7: remote -> jee6-sandbox-demo-archetype (-)
8: remote -> jee6-servlet-basic-archetype (-)
9: remote -> jee6-servlet-demo-archetype (-)
10: remote -> jee6-servlet-minimal-archetype (-)
11: remote -> jee6-servlet-sandbox-archetype (-)
12: remote -> imixs-workflow-jee-archetype (Imixs Workflow JEE Archetype provides a JEE Sample Application)
13: remote -> weld-jsf-jee (Weld archetype for creating a Java EE 6 application using JSF 2.0, CDI 1.0, EJB 3.1 and JPA 2.0 (persistence unit included))
14: remote -> weld-jsf-jee-minimal (Weld archetype for creating a minimal Java EE 6 application using JSF 2.0, CDI 1.0 and EJB 3.1 (persistence unit not included))
Choose a number: : 13
Downloading: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.jar
Downloaded: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.jar (138 KB at 121.2 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.pom
Downloaded: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.pom (2 KB at 1.9 KB/sec)
Define value for property 'groupId': : foo.bar
Define value for property 'artifactId': : weldy
[INFO] Using property: version = 1.0.0-SNAPSHOT
Define value for property 'package':  foo.bar: : 
Confirm properties configuration:
groupId: foo.bar
artifactId: weldy
version: 1.0.0-SNAPSHOT
package: foo.bar
 Y: : 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31.635s
[INFO] Finished at: Sun May 01 00:09:10 CEST 2011
[INFO] Final Memory: 6M/245M
[INFO] ------------------------------------------------------------------------

{noformat}

Basically, the code in org.apache.maven.archetype.ui.DefaultArchetypeSelector looks like :

{noformat}
    public void selectArchetype( ArchetypeGenerationRequest request, Boolean interactiveMode, String catalogs )
        throws ArchetypeNotDefined, UnknownArchetype, UnknownGroup, IOException, PrompterException,
        ArchetypeSelectionFailure
    {
        ...
        Map<String, List<Archetype>> archetypes = getFilteredArchetypes(getArchetypesByCatalog( catalogs ), 
                                                                                                request.getFilter() );
        ...
{noformat}

{noformat}
    private Map<String, List<Archetype>> getFilteredArchetypes(	Map<String, List<Archetype>> archetypesByCatalog, 
    															final String filter) {
    	
    	if (StringUtils.isNotEmpty(filter) && !archetypesByCatalog.isEmpty()) 
    	{
    		Iterator<Map.Entry<String, List<Archetype>>> ite = archetypesByCatalog.entrySet().iterator();
    		while (ite.hasNext()) {
    			Map.Entry<String, List<Archetype>> entry = ite.next();
    			List<Archetype> archetypes  = entry.getValue();
    			CollectionUtils.filter(archetypes, new Predicate() 
            	{
					public boolean evaluate(Object archetype) 
					{
						return ((Archetype) archetype).getArtifactId().contains(filter);
					}
				});
    			if (archetypes.isEmpty()) {
    				ite.remove();
    			}
    		}
    	}
		return archetypesByCatalog;
	}
{noformat}

This implementation has a minimum impact on the code. However, doing the actual filtering would probably be more appropriate directly in the ArchetypeCatalog class, but that would require more code change. It's debatable.

If this implementation suits you, I can add some test cases and attach a patch here. You tell me :-)



      was (Author: fbricon):
    After a bit of hacking, I managed to get the following results :

{noformat}
[fbricon@fbricon Temp]$ mvn org.apache.maven.plugins:maven-archetype-plugin:2.1-SNAPSHOT:generate -Dfilter=jee
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.1-SNAPSHOT:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: remote -> ear-jee5 (-)
2: remote -> ejb-jee5 (-)
3: remote -> webapp-jee5 (-)
4: remote -> jee6-basic-archetype (-)
5: remote -> jee6-minimal-archetype (-)
6: remote -> jee6-sandbox-archetype (-)
7: remote -> jee6-sandbox-demo-archetype (-)
8: remote -> jee6-servlet-basic-archetype (-)
9: remote -> jee6-servlet-demo-archetype (-)
10: remote -> jee6-servlet-minimal-archetype (-)
11: remote -> jee6-servlet-sandbox-archetype (-)
12: remote -> imixs-workflow-jee-archetype (Imixs Workflow JEE Archetype provides a JEE Sample Application)
13: remote -> weld-jsf-jee (Weld archetype for creating a Java EE 6 application using JSF 2.0, CDI 1.0, EJB 3.1 and JPA 2.0 (persistence unit included))
14: remote -> weld-jsf-jee-minimal (Weld archetype for creating a minimal Java EE 6 application using JSF 2.0, CDI 1.0 and EJB 3.1 (persistence unit not included))
Choose a number: : 13
Downloading: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.jar
Downloaded: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.jar (138 KB at 121.2 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.pom
Downloaded: http://repo1.maven.org/maven2/org/jboss/weld/archetypes/weld-jsf-jee/1.0.0-BETA1/weld-jsf-jee-1.0.0-BETA1.pom (2 KB at 1.9 KB/sec)
Define value for property 'groupId': : foo.bar
Define value for property 'artifactId': : weldy
[INFO] Using property: version = 1.0.0-SNAPSHOT
Define value for property 'package':  foo.bar: : 
Confirm properties configuration:
groupId: foo.bar
artifactId: weldy
version: 1.0.0-SNAPSHOT
package: foo.bar
 Y: : 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31.635s
[INFO] Finished at: Sun May 01 00:09:10 CEST 2011
[INFO] Final Memory: 6M/245M
[INFO] ------------------------------------------------------------------------

{noformat}

Basically, the code in org.apache.maven.archetype.ui.DefaultArchetypeSelector looks like :

{noformat}
    public void selectArchetype( ArchetypeGenerationRequest request, Boolean interactiveMode, String catalogs )
        throws ArchetypeNotDefined, UnknownArchetype, UnknownGroup, IOException, PrompterException,
        ArchetypeSelectionFailure
    {
        ...
        Map<String, List<Archetype>> archetypes = getFilteredArchetypes(getArchetypesByCatalog( catalogs ), 
                                                                                                request.getFilter() );
        ...
{noformat}

{noformat}
    private Map<String, List<Archetype>> getFilteredArchetypes(	Map<String, List<Archetype>> archetypesByCatalog, 
    															final String filter) {
    	
    	if (StringUtils.isNotEmpty(filter) && !archetypesByCatalog.isEmpty()) 
    	{
        	for (Map.Entry<String, List<Archetype>> entry : archetypesByCatalog.entrySet()) 
        	{
            	CollectionUtils.filter(entry.getValue(), new Predicate() 
            	{
					public boolean evaluate(Object archetype) 
					{
						return ((Archetype) archetype).getArtifactId().contains(filter);
					}
				});
        	}
    	}
		return archetypesByCatalog;
	}
{noformat}

This implementation has a minimum impact on the code. However, doing the actual filtering would probably be more appropriate directly in the ArchetypeCatalog class, but that would require more code change. It's debatable.

If this implementation suits you, I can add some test cases and attach a patch here. You tell me :-)


  
> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: http://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272382#comment-272382 ] 

Olivier Lamy commented on ARCHETYPE-371:
----------------------------------------

for simplicity something like -Dfilter=groupId:artifactId 
Both must be included in groupId and artifactId.
Seems more simple than the g:,a:

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Closed: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
     [ https://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Olivier Lamy closed ARCHETYPE-371.
----------------------------------

    Resolution: Fixed

documentation added.
I have take care of case where filter doesn't return any values.
Have Fun :-)

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: https://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>            Assignee: Olivier Lamy
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (ARCHETYPE-371) Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate

Posted by "Herve Boutemy (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/ARCHETYPE-371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=265995#action_265995 ] 

Herve Boutemy commented on ARCHETYPE-371:
-----------------------------------------

I'm interested in this feature: yes, please provide patch with test cases :)

> Add a command line argument to filter/limit the archetypes returned by mvn archetype:generate
> ---------------------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-371
>                 URL: http://jira.codehaus.org/browse/ARCHETYPE-371
>             Project: Maven Archetype
>          Issue Type: New Feature
>          Components: Plugin
>    Affects Versions: 2.0
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/local/maven
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Default locale: fr_FR, platform encoding: UTF-8
> OS name: "linux", version: "2.6.35.12-90.fc14.x86_64", arch: "amd64", family: "unix"
>            Reporter: Fred Bricon
>             Fix For: 2.1
>
>
> Currently, running mvn archetype:generate returns 390 archetypes, on my machine.
> By default, th window buffer of my terminal isn't set big enough so I can see the first archetypes in the list.
> So, I think it would be really useful to have a CLI arg allowing us to filter the archetypes containing a string.
> Ex: running {code}mvn archetype:generate -Dfilter=webapp{code} would return only the archetypes having webapp in their artifactId.
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira