-
Notifications
You must be signed in to change notification settings - Fork 49
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
Added Template based Project Wizard #499
base: main
Are you sure you want to change the base?
Conversation
keinhaar
commented
Sep 29, 2024
- Create projects based on templates.
- removed some unused code
- added a multi project template without example code
- added a multi project GWT project template with the example code from the existing GWT sample project, but splitted into 3 projects.
- Create projects based on templates. - removed some unused code - added a multi project template without example code - added a multi project GWT project template with the example code from the existing GWT sample project, but splitted into 3 projects.
@keinhaar this PR looks great, and the implementation looks simply reasonable.
BTW the solution is expandable either by adding to the template dir, or defining an env variable. Not bad! |
It just uses modified versions of the files that are created by the sdk.
maven based example could be added easily by just providing a template with pom files. I did not create more templates, because i did not know if this would be accepted.
The env variable makes it possible to create and use your own custom templates. Thats what i personally would like to use, because my applications often have 5 or even 6 projects which depend on each other. |
@keinhaar Thanks for contributing. And, having a template project using Spring Boot on the server side would be fine. ;-) |
Just use the archetype creators for generating the template files:
These are the suggested way creating a new project: https://www.gwtproject.org/gettingstarted-v2.html |
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.
A lot of this is pretty eclipse-specific, I'm not sure how helpful I can be. Here's a quick review, but I think it would make more sense for someone who knows the project more deeply to dig in than me.
@@ -0,0 +1,130 @@ | |||
/******************************************************************************* | |||
* Copyright 2011 Google Inc. All Rights Reserved. |
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.
new files, should have updated copyright date, and owner
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.
Fixed this
@@ -0,0 +1,171 @@ | |||
/** | |||
* |
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.
should be populated, or removed?
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.
Fixed this
javaProjects = webAppProjectCreator.getCreatedJavaProjects(); | ||
if (javaProjects == null) { |
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.
it doesnt appear that this should never return null - would it make more sense to test if empty? also, what do you think about List<IJavaProject>
?
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.
changed this to list
pom.xml
Outdated
@@ -11,7 +11,7 @@ | |||
<properties> | |||
<tycho.version>3.0.1</tycho.version> | |||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |||
<eclipse.target>2022-09</eclipse.target> <!-- TODO change to neon --> | |||
<eclipse.target>2023-09</eclipse.target> <!-- TODO change to neon --> |
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.
probably can remove that TODO as long as you're updating the line...
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.
removed todo
<!-- allow Super Dev Mode --> | ||
<add-linker name="xsiframe"/> |
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.
No longer needed since GWT 2.7, almost 10 years gwtproject/gwt@22865ad
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.
removed the xsiframe
throw new IOException("File to large"); | ||
} | ||
byte[] data = Files.readAllBytes(path); | ||
String str = new String(data, cset); |
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.
Are you sure we want the default charset here, rather than just assuming utf8 everywhere?
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.
changed to UTF-8
BufferedWriter writer = Files.newBufferedWriter(path, cset); | ||
writer.write(newStr); | ||
writer.close(); |
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.
try-with-resources, otherwise if the write fails this might not get closed (and then you've got a broken project, and windows won't let it be deleted or the like)
(goes away if you use Files.write())
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.
changed to Files.writeString()
* @param file | ||
* @throws CoreException | ||
*/ | ||
public static void reformatJavaSource(File file) throws CoreException { | ||
try { | ||
String generatedSource = textFromFile(file); | ||
String generatedSource = Files.readString(file.toPath(), Charset.defaultCharset()); |
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.
consider if we really want the default charset here, or just assume utf8?
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 has been default charset in the previous implementation. Didn't want to change that. Just simplified the Code by using an existing JRE method.
String str = new String(data, cset); | ||
String newStr = str.replaceAll(pattern, replacement); | ||
BufferedWriter writer = Files.newBufferedWriter(path, cset); | ||
writer.write(newStr); |
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.
if we've got the full string in memory... why buffer? why not just use Files.write(...)?
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.
see comment above
String name = file.getName(); | ||
name = name.replace("_PACKAGENAME_", packageBaseName.replace('.', File.separatorChar)); | ||
File newFile = new File(file.getParentFile(), name); | ||
newFile.getParentFile().mkdirs(); |
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.
consider using java.nio.Files.createDirectories(..) here - the Files class will throw instead of silently fail (or letting you ignore the return value, as you're doing here).
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.
changed to createDirectories
- javaProjects as List instead of Array - Copyright information updated / inserted - Fixed multithreading bug - removed xsiframe from gwt.xml file - replaced mkdirs() with Files.createDirectories() - Use UTF-8 instead of defaultCharset -Use Files.writeString() instead of BufferedWriter
- all renaming of files is done by using the same method. - allow filenames to contain the placeholder _PROJECTNAME_
I've created a maven based template using the instructions on the gettingstarted-v2 page. It runs just fine if used with maven, but there are some problems running it from eclipse:
To make it work from eclipse the following steps are required:
I'm in doubt if i should add it in this state. |
@protoism |