-
Notifications
You must be signed in to change notification settings - Fork 116
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
Let maven do the hard work of archetype generation #767
Conversation
org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/IMavenLauncher.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks very good.
Addressing the potential crashing of Eclipse by post scripts is IMHO important and this looks like a good step forward to maybe even get completely rid of the embedded archetype dependency?
I basically only have one remark: Could you please provide a more descriptive commit message, like: Generate archtetype projects in separate Maven-build process
org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/IMavenLauncher.java
Outdated
Show resolved
Hide resolved
da19243
to
64966dd
Compare
I'm struggling a bit to get the test repo filled completely (I probably will enable online maven central as it otherwise becomes really cumbersome), but the code itself is now functional and thus is ready to be reviewed. |
64966dd
to
14b8e24
Compare
All tests are green now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this looks good to me.
I just have a few minor remarks.
org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/archetype/ArchetypeGenerator.java
Outdated
Show resolved
Hide resolved
org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/archetype/ArchetypeGenerator.java
Outdated
Show resolved
Hide resolved
throw new CoreException(Status.error(msg, cause)); | ||
String goals = "-U org.apache.maven.plugins:maven-archetype-plugin:2.4:generate"; | ||
if(emptyPom != null) { | ||
goals += " -f " + emptyPom.getAbsolutePath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this logic new? Maybe it should be rejected with an error to create an archetype project where a pom.xml file already exists instead of using an alternative pom that is deleted afterwards.
Is the created project then valid after the empty-pom used for creation is deleted? Or is there a relevant use case for such scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by 'new'? This is to prevent m2e to first generate the code at a temporary place and then move it around, without the empty pom you will get higher build times and can't create a module of a parent that has pom-errors and at least there is a test for that (don't know if it uses intentionally an incomplete module pom).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way there are currently two restrictions one might report to maven and submit a patch, but this would then take some time until it is released:
- If running
mvn
inside an empty folder / without a pom, it uses a "no-pom build", one can then force a different location of the pom by -f but if the folder contains no pom I can't force to ignore that file. - maven-archetype always generates the archetype at the folder
$outputDir/$artifactId
while here it would be good if we can just generate it in the current folder (what would be empty anyways).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by 'new'? This is to prevent m2e to first generate the code at a temporary place and then move it around, without the empty pom you will get higher build times and can't create a module of a parent that has pom-errors and at least there is a test for that (don't know if it uses intentionally an incomplete module pom).
I meant if that the logic you just described was available before too.
Nevertheless what you describe sounds very reasonable. Thank you for your elaboration.
org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizard.java
Outdated
Show resolved
Hide resolved
org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
Outdated
Show resolved
Hide resolved
org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizard.java
Outdated
Show resolved
Hide resolved
org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/EclipseMavenLauncher.java
Outdated
Show resolved
Hide resolved
org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java
Show resolved
Hide resolved
org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
Show resolved
Hide resolved
@HannesWell I have applied your suggestion and fixed the compile issues, if you are fine I'll swash all content into one before merge... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thank you.
@HannesWell I have applied your suggestion and fixed the compile issues, if you are fine I'll swash all content into one before merge...
Sure squash it, I see no need to keep the review history in git. :)
org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java
Show resolved
Hide resolved
} | ||
Files.writeString(tempFile.toPath(), | ||
"<project><modelVersion>4.0.0</modelVersion><groupId>empty</groupId><artifactId>empty</artifactId><version>1</version><name>Generating archetype</name></project>", | ||
StandardCharsets.UTF_8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed that Files.writeString() uses UTF-8 by default so specifying the charset explicitly is actually not necessary.
throw new CoreException(Status.error(msg, cause)); | ||
String goals = "-U org.apache.maven.plugins:maven-archetype-plugin:2.4:generate"; | ||
if(emptyPom != null) { | ||
goals += " -f " + emptyPom.getAbsolutePath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by 'new'? This is to prevent m2e to first generate the code at a temporary place and then move it around, without the empty pom you will get higher build times and can't create a module of a parent that has pom-errors and at least there is a test for that (don't know if it uses intentionally an incomplete module pom).
I meant if that the logic you just described was available before too.
Nevertheless what you describe sounds very reasonable. Thank you for your elaboration.
org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
Show resolved
Hide resolved
org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/EclipseMavenLauncher.java
Outdated
Show resolved
Hide resolved
cd483ef
to
9074c27
Compare
Okay, lets merge when build runs fine then (after reverting the modules link). |
Prerequisite for eclipse-m2e#249 Co-authored-by: Hannes Wellmann <[email protected]>
9074c27
to
371a0b7
Compare
I still don't like much IMavenLauncher (but at least it's internal, so not a too big deal)
Couldn't this be a new method to AbstractMavenRuntime then, something like |
If you like, just try it out I won't mind adjusting that part of the code as it is covered by tests and not used elsewhere until now we can change relative easy here. |
Prerequisite for #249