[JBoss JIRA] (ROASTER-62) Roaster - adds java.lang.xxx imports which is automatic in Java
by Nicolas Challut (JIRA)
[ https://issues.jboss.org/browse/ROASTER-62?page=com.atlassian.jira.plugin... ]
Nicolas Challut commented on ROASTER-62:
----------------------------------------
Whao, dat tricky way to create a class oO
You could use this way (import are automatic) :
{code}
JavaClassSource source = Roaster.create(JavaClassSource.class);
source.setName("Bar");
source.setSuperType("org.apache.camel.builder.RouteBuilder");
{code}
but you're right, addThrows should not import java.lang.Exception
> Roaster - adds java.lang.xxx imports which is automatic in Java
> ---------------------------------------------------------------
>
> Key: ROASTER-62
> URL: https://issues.jboss.org/browse/ROASTER-62
> Project: Roaster
> Issue Type: Bug
> Environment: Using Forge 2.14.0 so I use the Roaster that is shipped
> Reporter: Claus Ibsen
> Priority: Minor
>
> I have this code that creates a Apache Camel class for building routes.
> {code}
> // need to parse to be able to extends another class
> String top = String.format("public class %s extends RouteBuilder {}", name.getValue());
> final JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, top);
> if (targetPackage.getValue() != null) {
> javaClass.setPackage(targetPackage.getValue());
> }
> javaClass.addImport("org.apache.camel.builder.RouteBuilder");
> javaClass.addMethod()
> .setPublic()
> .setReturnTypeVoid()
> .setName("configure")
> .setBody("from(\"timer:foo\").to(\"log:foo\");")
> .addThrows(Exception.class);
> facet.saveJavaSource(javaClass);
> {code}
> Notice that the configure method has a throws java.lang.Exception.
> The generated source code has import java.lang.Exception which is automatic in java, and all java.lang is auto imported and not to be defined.
> The generated code
> {code}
> davsclaus:/opt/forge-distribution-2.14.0.Final/mydemo/$ cat src/main/java/com/foo/Bar.java
> package com.foo;
> import org.apache.camel.builder.RouteBuilder;
> import java.lang.Exception;
> public class Bar extends RouteBuilder
> {
> public void configure() throws Exception
> {
> from("timer:foo").to("log:foo");
> }
> }davsclaus:/opt/forge-distribution-2.14.0.Final/mydemo/$ mvn clean install
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
9 years, 4 months
[JBoss JIRA] (ROASTER-63) JavaClassSource - Cannot extend another class when using the fluent builder
by Claus Ibsen (JIRA)
Claus Ibsen created ROASTER-63:
----------------------------------
Summary: JavaClassSource - Cannot extend another class when using the fluent builder
Key: ROASTER-63
URL: https://issues.jboss.org/browse/ROASTER-63
Project: Roaster
Issue Type: Enhancement
Reporter: Claus Ibsen
I need to create a java class that extends another. As there is no .addExtends or .extends or something I had to work around and use the parse.
I can only find an .addInterface
Here is the code I use with my workaround
{code}
// need to parse to be able to extends another class
String top = String.format("public class %s extends RouteBuilder {}", name.getValue());
final JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, top);
if (targetPackage.getValue() != null) {
javaClass.setPackage(targetPackage.getValue());
}
{code}
eg what I want to do is
{code}
javaClass.extends("RouteBuilder");
{code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
9 years, 4 months
[JBoss JIRA] (ROASTER-62) Roaster - adds java.lang.xxx imports which is automatic in Java
by Claus Ibsen (JIRA)
Claus Ibsen created ROASTER-62:
----------------------------------
Summary: Roaster - adds java.lang.xxx imports which is automatic in Java
Key: ROASTER-62
URL: https://issues.jboss.org/browse/ROASTER-62
Project: Roaster
Issue Type: Bug
Environment: Using Forge 2.14.0 so I use the Roaster that is shipped
Reporter: Claus Ibsen
Priority: Minor
I have this code that creates a Apache Camel class for building routes.
{code}
// need to parse to be able to extends another class
String top = String.format("public class %s extends RouteBuilder {}", name.getValue());
final JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, top);
if (targetPackage.getValue() != null) {
javaClass.setPackage(targetPackage.getValue());
}
javaClass.addImport("org.apache.camel.builder.RouteBuilder");
javaClass.addMethod()
.setPublic()
.setReturnTypeVoid()
.setName("configure")
.setBody("from(\"timer:foo\").to(\"log:foo\");")
.addThrows(Exception.class);
facet.saveJavaSource(javaClass);
{code}
Notice that the configure method has a throws java.lang.Exception.
The generated source code has import java.lang.Exception which is automatic in java, and all java.lang is auto imported and not to be defined.
The generated code
{code}
davsclaus:/opt/forge-distribution-2.14.0.Final/mydemo/$ cat src/main/java/com/foo/Bar.java
package com.foo;
import org.apache.camel.builder.RouteBuilder;
import java.lang.Exception;
public class Bar extends RouteBuilder
{
public void configure() throws Exception
{
from("timer:foo").to("log:foo");
}
}davsclaus:/opt/forge-distribution-2.14.0.Final/mydemo/$ mvn clean install
{code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
9 years, 4 months
[JBoss JIRA] (FORGE-2245) ResourceFactory : creating a resource from a file
by Jerome B (JIRA)
Jerome B created FORGE-2245:
-------------------------------
Summary: ResourceFactory : creating a resource from a file
Key: FORGE-2245
URL: https://issues.jboss.org/browse/FORGE-2245
Project: Forge
Issue Type: Bug
Components: Resources
Affects Versions: 2.13.1.Final
Environment: w764, java 7
Reporter: Jerome B
As I was trying to use a file contained in the JAR of my addon, I used this (intuitive) code
URL voilaURL = getClass().getClassLoader().getResource("voila.txt");
File f = new File(voilaURL.toExternalForm());
Resource<?> resource = rfactory.create(f); // KO
FileResource fresource = rfactory.create(FileResource.class, f); // KO
both last two line lead to a FileResource which, in debug is displayed as this form
[PROJECT_ROOT][Correct full path of file in jar]
D:\workspace_addons\ADDONS\jar:file:\C:\Users\me\.forge\addons\fr-company-addons-ADDONS213b-1-0-1-SNAPSHOT\ADDONS213b-1.0.1-SNAPSHOT-forge-addon.jar!\voila.txt
Then, those FileResources when used with the templateFactory
Template template = tfactory.create(resource,FreemarkerTemplate.class);
lead to an error like "template does not exist"
Hint?: The toString value is wrong but the path of the file within FileResource is ok
See https://developer.jboss.org/thread/252367 for more data
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
9 years, 4 months
[JBoss JIRA] (FORGE-2243) Programmatically added maven archetype catalog does not work with new-project
by Claus Ibsen (JIRA)
Claus Ibsen created FORGE-2243:
----------------------------------
Summary: Programmatically added maven archetype catalog does not work with new-project
Key: FORGE-2243
URL: https://issues.jboss.org/browse/FORGE-2243
Project: Forge
Issue Type: Bug
Affects Versions: 2.14.0.Final
Reporter: Claus Ibsen
See also FORGE-2242
When using the new-project command it doesnt work with catalogs that has been added from java code.
I have added an archetype catalog named "central", eg see FORGE-2242, and when I use it in project-new it fails, as the last output.
{code}
[forge-distribution-2.14.0.Final]$ project-new
***INFO*** Required inputs not satisfied, entering interactive mode
? Project name: mydemo2
? Top level package [org.mydemo2]:
? Version [1.0.0-SNAPSHOT]:
? Final name:
? Project location [/opt/forge-distribution-2.14.0.Final]:
[0] (x) war
[1] ( ) jar
[2] ( ) parent
[3] ( ) addon
[4] ( ) resource-jar
[5] ( ) ear
[6] ( ) from-archetype
[7] ( ) from-archetype-catalog
Press <ENTER> to confirm, or <CTRL>+C to cancel.
? Project type: [0-7] 7
[0] (x) Maven
Press <ENTER> to confirm, or <CTRL>+C to cancel.
? Build system: [0]
[0] ( ) central
Press <ENTER> to confirm, or <CTRL>+C to cancel.
? Catalog: [0]
***ERROR*** Catalog must be specified.
***ERROR*** Archetype must be specified.
[forge-distribution-2.14.0.Final]$
{code}
But if I add an archetype catalog using archetype-add from the forge shell then it works with project-new, even though they both load the same set of archetypes from maven central.
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
9 years, 4 months
[JBoss JIRA] (FORGE-2242) Programmatically adding maven archetype catalog - is shown as unknown in archetype-list
by Claus Ibsen (JIRA)
Claus Ibsen created FORGE-2242:
----------------------------------
Summary: Programmatically adding maven archetype catalog - is shown as unknown in archetype-list
Key: FORGE-2242
URL: https://issues.jboss.org/browse/FORGE-2242
Project: Forge
Issue Type: Bug
Affects Versions: 2.14.0.Final
Reporter: Claus Ibsen
Priority: Minor
When installing the Camel forge commands we want to install the Camel archetypes as a catalog out of the box.
I got some code that does that (but currently coded to include all from central, but we will filter out this later)
{code}
// TODO: Remove when when using Forge 2.14.1+
void startup(@Observes @Local PostStartup startup, ArchetypeCatalogFactoryRegistry registry) {
// registry.addArchetypeCatalogFactory(this);
try {
URL url = new URL("http://repo2.maven.org/maven2/archetype-catalog.xml");
String defaultRepo = extractRepository(url);
registry.addArchetypeCatalogFactory("central", url, defaultRepo);
} catch (MalformedURLException e) {
logger.log(Level.SEVERE, "Error while retrieving archetypes", e);
}
}
{code}
But the archeype-list command shows this as unknown.
{code}
[forge-distribution-2.14.0.Final]$ addon-install --coordinate io.fabric8.forge:camel,2.2-SNAPSHOT
***SUCCESS*** Addon io.fabric8.forge:camel,2.2-SNAPSHOT was installed successfully.
[forge-distribution-2.14.0.Final]$ archetype-list
central = unknown
{code}
If I add the archetype manually using archetype-add then the url is listed correctly.
As I am using the add command that takes an URL then it should be shown
{code}
void addArchetypeCatalogFactory(String name, URL catalogURL, String defaultRepositoryName);
{code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
9 years, 4 months
[JBoss JIRA] (FORGE-2239) Auto pickup of ArchetypeCatalogFactory instances from AddonRegistry is not working
by Claus Ibsen (JIRA)
[ https://issues.jboss.org/browse/FORGE-2239?page=com.atlassian.jira.plugin... ]
Claus Ibsen commented on FORGE-2239:
------------------------------------
Yay thanks a lot.
> Auto pickup of ArchetypeCatalogFactory instances from AddonRegistry is not working
> ----------------------------------------------------------------------------------
>
> Key: FORGE-2239
> URL: https://issues.jboss.org/browse/FORGE-2239
> Project: Forge
> Issue Type: Bug
> Components: Build Tools - Maven
> Affects Versions: 2.14.0.Final
> Environment: Using a vanilla Forge 2.14.0 from the command line
> Reporter: Claus Ibsen
> Assignee: George Gastaldi
> Fix For: 2.14.1.Final
>
>
> I try to create a new project, and select [7] to select from maven archetype catalog, but the values for catalog and archetype cannot be entered. I am not sure how its supposed to work.
> Here is what I did
> {code}
> [forge-distribution-2.14.0.Final]$ project-new
> ***INFO*** Required inputs not satisfied, entering interactive mode
> ? Project name: muydemo
> ? Top level package [org.muydemo]:
> ? Version [1.0.0-SNAPSHOT]:
> ? Final name:
> ? Project location [/opt/forge-distribution-2.14.0.Final]:
> [0] (x) war
> [1] ( ) jar
> [2] ( ) parent
> [3] ( ) addon
> [4] ( ) ear
> [5] ( ) resource-jar
> [6] ( ) from-archetype
> [7] ( ) from-archetype-catalog
> Press <ENTER> to confirm, or <CTRL>+C to cancel.
> ? Project type: [0-7] 7
> [0] (x) Maven
> Press <ENTER> to confirm, or <CTRL>+C to cancel.
> ? Build system: [0]
> ***ERROR*** Catalog must be specified.
> ***ERROR*** Archetype must be specified.
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
9 years, 4 months
[JBoss JIRA] (FORGE-2239) Auto pickup of ArchetypeCatalogFactory instances from AddonRegistry is not working
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/FORGE-2239?page=com.atlassian.jira.plugin... ]
George Gastaldi updated FORGE-2239:
-----------------------------------
Summary: Auto pickup of ArchetypeCatalogFactory instances from AddonRegistry is not working (was: project-new - Cannot create a new project from-archetype-catalog)
> Auto pickup of ArchetypeCatalogFactory instances from AddonRegistry is not working
> ----------------------------------------------------------------------------------
>
> Key: FORGE-2239
> URL: https://issues.jboss.org/browse/FORGE-2239
> Project: Forge
> Issue Type: Bug
> Affects Versions: 2.14.0.Final
> Environment: Using a vanilla Forge 2.14.0 from the command line
> Reporter: Claus Ibsen
> Assignee: George Gastaldi
> Fix For: 2.14.1.Final
>
>
> I try to create a new project, and select [7] to select from maven archetype catalog, but the values for catalog and archetype cannot be entered. I am not sure how its supposed to work.
> Here is what I did
> {code}
> [forge-distribution-2.14.0.Final]$ project-new
> ***INFO*** Required inputs not satisfied, entering interactive mode
> ? Project name: muydemo
> ? Top level package [org.muydemo]:
> ? Version [1.0.0-SNAPSHOT]:
> ? Final name:
> ? Project location [/opt/forge-distribution-2.14.0.Final]:
> [0] (x) war
> [1] ( ) jar
> [2] ( ) parent
> [3] ( ) addon
> [4] ( ) ear
> [5] ( ) resource-jar
> [6] ( ) from-archetype
> [7] ( ) from-archetype-catalog
> Press <ENTER> to confirm, or <CTRL>+C to cancel.
> ? Project type: [0-7] 7
> [0] (x) Maven
> Press <ENTER> to confirm, or <CTRL>+C to cancel.
> ? Build system: [0]
> ***ERROR*** Catalog must be specified.
> ***ERROR*** Archetype must be specified.
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
9 years, 4 months