Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Maven pom.xml to build model #1396

Closed
msteinbeck opened this issue Jun 12, 2017 · 9 comments · Fixed by #1533
Closed

Using Maven pom.xml to build model #1396

msteinbeck opened this issue Jun 12, 2017 · 9 comments · Fixed by #1533
Labels

Comments

@msteinbeck
Copy link
Contributor

Is it possible to create a Spoon model from a single pom.xml? Since the pom contains all dependencies, it should be possible to create a model without noclasspath mode. This feature is not limited to Maven, but could also be added for Ant, Gradle, and even Eclipse project files.

@surli
Copy link
Collaborator

surli commented Jun 12, 2017

Just to clarify: you mean to be able to launch Spoon in specifying only a targeted pom.xml and to let Spoon analyze the file and create the model from sources, using the proper dependencies?

I like the idea, but I'm not sure if it should be integrated to spoon-core, or if it should be another project which can analyze the pom.xml and then call Spoon with the proper arguments...

@msteinbeck
Copy link
Contributor Author

Just to clarify: you mean to be able to launch Spoon in specifying only a targeted pom.xml and to let Spoon analyze the file and create the model from sources, using the proper dependencies?

Let me put it in other words: Java

Launcher launcher = new Launcher();
launcher.addInputResource("./pom.xml");
launcher.buildModel();
CtModel completeModel = launcher.getModel();

So yes, I would like to add only a pom.xml and create a complete model out of it.

I like the idea, but I'm not sure if it should be integrated to spoon-core, or if it should be another project which can analyze the pom.xml and then call Spoon with the proper arguments...

Why would you like to put this feature into another project? Spoon is all about creating models from Java source code, isn't it :). With a little bit of luck, there already is a Maven parser.

@surli
Copy link
Collaborator

surli commented Jun 13, 2017

Why would you like to put this feature into another project? Spoon is all about creating models from Java source code, isn't it :).

Actually I was thinking about spoon-maven-plugin which is another project, so do we want to include this feature inside spoon-core, or not. Yes, we could do as you propose but maybe it would be better to explicit the fact the pom.xml input resource will impact the classpath and so one.

So maybe something like this would be better, WDYT?

Launcher launcher = new Launcher();
launcher.setPomProject("./pom.xml");
launcher.buildModel();
CtModel completeModel = launcher.getModel();

With a little bit of luck, there already is a Maven parser.

See: http://maven.apache.org/components/ref/3.2.5/maven-model/

@surli surli added the feature label Jun 13, 2017
@pvojtechovsky
Copy link
Collaborator

I vote to put it into another project too. Otherwise the spoon core needs a dependency to

  • maven project parser
  • to libraries which can download dependencies from maven repository ...

@surli
Copy link
Collaborator

surli commented Jun 14, 2017

Otherwise the spoon core needs a dependency to

  • maven project parser
  • to libraries which can download dependencies from maven repository ...

I assume you don't want those dependencies because of the size of the libraries to add. So as a check I tested to package spoon with and without the new dependency for Maven model resolver, here are the results:

Kwak-Spirals:spoon urli$ du -k target/spoon-core-5.8.0-SNAPSHOT-jar-with-dependencies.jar 
7264	target/spoon-core-5.8.0-SNAPSHOT-jar-with-dependencies.jar
Kwak-Spirals:spoon urli$ du -k target/spoon-core-5.8.0-SNAPSHOT-jar-with-dependencies.jar 
10112	target/spoon-core-5.8.0-SNAPSHOT-jar-with-dependencies.jar

So around 3 Mb more with the new dependency.

@msteinbeck
Copy link
Contributor Author

So around 3 Mb more with the new dependency.

To be honest, that's nothing much compared to JDT (5.6M). Furthermore, the libraries used to download dependencies from Maven repositories can be reused for a potential Gradle parser.

@surli
Copy link
Collaborator

surli commented Jun 14, 2017

To be honest, that's nothing much compared to JDT (5.6M).

I tend to agree: i'm not sure it's a real issue to add 3 Mb to the full jar. WDYT @pvojtechovsky @monperrus ?

@monperrus
Copy link
Collaborator

I'm in favor of this proposal because:

  1. the main goal of Spoon is to create models of Java source code
  2. it is fully backward compatible
  3. the memory overhead is acceptable

@pvojtechovsky
Copy link
Collaborator

I personally do not need this feature and if you want it in spoon core, then I really have no problem with that ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants