ingenieux / jbake-maven-plugin

JBake Maven Plugin
14 stars 23 forks source link

add a flag to add maven dependencies to the classpath #16

Open rmannibucau opened 8 years ago

rmannibucau commented 8 years ago

idea would be to add dependencies and target/classes to be able to use in gsp some utility developped in src/main/java or a dependency (these ones can be added to the plugin but when using some utility from src/main/java in a dedicated module it is a big copy/paste we can avoid).

aldrinleal commented 8 years ago

looks possible. I'll go take a look

-- Aldrin Leal, aldrin@leal.eng.br / http://about.me/aldrinleal

On Thu, Mar 17, 2016 at 8:56 AM, Romain Manni-Bucau < notifications@github.com> wrote:

idea would be to add dependencies and target/classes to be able to use in gsp some utility developped in src/main/java or a dependency (these ones can be added to the plugin but when using some utility from src/main/java in a dedicated module it is a big copy/paste we can avoid).

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/ingenieux/jbake-maven-plugin/issues/16

aldrinleal commented 8 years ago

Romain,

I've made two things:

  1. Adding it to phase process-classes (post-compile, thus)
  2. Set it effectively into runtime scope, thus able to share the classloading of whatever is kept under src/main/java

give it a try

rmannibucau commented 8 years ago

Hi Aldrin,

get an exception trying to build:

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project br.com.ingenieux:jbake-maven-plugin:0.3.0-SNAPSHOT (C:\Users\romain\.babun\cygwin\tmp\jbake-maven-plugin\pom.xml) has 1 error
[ERROR]     Non-parseable POM C:\Users\romain\.babun\cygwin\tmp\pom.xml: only whitespace content allowed before start tag and not \u1b (position: START_DOCUMENT seen \u1b... @1:1)  @ C:\Users\romain\.babun\cygwin\tmp\pom.xml, line 1, column 1 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

Didn't dig but seems like a "hidden" char at the beginning of the pom. I didn't see how to add target/classes or another location to the build in the diff. Normally maven doesn't do it by default and the plugin needs IIRC. That said even if it does I would miss the project dependencies I think no?

aldrinleal commented 8 years ago

target/classes is added because of this:

@Mojo(name = "generate", requiresProject = true, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)

https://maven.apache.org/developers/mojo-api-specification.html

"Flags this Mojo as requiring the dependencies in the specified class path to be resolved before it can execute. The matrix below illustrates which values for (first column) are supported and which dependency scopes (first row) they will request to resolve:"

-- Aldrin Leal, aldrin@leal.eng.br / http://about.me/aldrinleal

On Sun, Apr 10, 2016 at 12:39 PM, Romain Manni-Bucau < notifications@github.com> wrote:

Hi Aldrin,

get an exception trying to build:

[INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project br.com.ingenieux:jbake-maven-plugin:0.3.0-SNAPSHOT (C:\Users\romain.babun\cygwin\tmp\jbake-maven-plugin\pom.xml) has 1 error [ERROR] Non-parseable POM C:\Users\romain.babun\cygwin\tmp\pom.xml: only whitespace content allowed before start tag and not \u1b (position: START_DOCUMENT seen \u1b... @1:1) @ C:\Users\romain.babun\cygwin\tmp\pom.xml, line 1, column 1 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

Didn't dig but seems like a "hidden" char at the beginning of the pom. I didn't see how to add target/classes or another location to the build in the diff. Normally maven doesn't do it by default and the plugin needs IIRC. That said even if it does I would miss the project dependencies I think no?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/ingenieux/jbake-maven-plugin/issues/16#issuecomment-208025924

rmannibucau commented 8 years ago

hmm, maybe I'm wrong but it resolves the dependencies but doesn't add them to the plugin classloader which is still under the mojo responsability like this https://github.com/apache/tomee/blob/master/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java#L410

aldrinleal commented 8 years ago

Then we need to be creative and come with a proof of concept then :)

rmannibucau commented 8 years ago

Don't have much time this month but idea was to use the plugin to generate new tomee website proposal: https://github.com/rmannibucau/site-tomee-ng. Temporarly I wrote my main https://github.com/rmannibucau/site-tomee-ng/blob/master/src/main/java/org/apache/tomee/website/JBake.java (and used tomee as http server ;)) but would be great to not have this code and I think it is doable.