-
Notifications
You must be signed in to change notification settings - Fork 843
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
Java Frontend Application wizard for Gradle #1154
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
32b8ab1
Creating project files from a layer.xml project archetype
dukescript e80e9f7
Include Gradle HTML UI wizard in the build
dukescript 2e7ad28
Adding license headers
dukescript 657726b
Use DEFAULT reload strategy
dukescript ee258eb
No need to specify the initParams properties
dukescript 28f106d
Merging definition of the template with the project's content
dukescript caa31fd
Merge remote-tracking branch 'origin/master' into GradleFrontendProject
dukescript e03eba2
Merge master into GradleFrontendProject
dukescript File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
|
||
--> | ||
<project basedir="." default="netbeans" name="groovy/gradle.htmlui"> | ||
<description>Builds, tests, and runs the project org.netbeans.modules.gradle.htmlui</description> | ||
<import file="../../nbbuild/templates/projectized.xml"/> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Manifest-Version: 1.0 | ||
AutoUpdate-Show-In-Client: true | ||
OpenIDE-Module: org.netbeans.modules.gradle.htmlui | ||
OpenIDE-Module-Layer: org/netbeans/modules/gradle/htmlui/resources/layer.xml | ||
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gradle/htmlui/Bundle.properties | ||
OpenIDE-Module-Recommends: org.netbeans.modules.debugger.jpda.ui | ||
OpenIDE-Module-Specification-Version: 1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
javac.source=1.7 | ||
javac.compilerargs=-Xlint -Xlint:-serial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
|
||
--> | ||
<project xmlns="http://www.netbeans.org/ns/project/1"> | ||
<type>org.netbeans.modules.apisupport.project</type> | ||
<configuration> | ||
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> | ||
<code-name-base>org.netbeans.modules.gradle.htmlui</code-name-base> | ||
<module-dependencies> | ||
<dependency> | ||
<code-name-base>org.netbeans.api.templates</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>1.6.1</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.netbeans.libs.freemarker</code-name-base> | ||
<run-dependency> | ||
<release-version>1</release-version> | ||
<specification-version>2.39</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.netbeans.modules.gradle</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>1.0</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.netbeans.modules.projectapi</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<release-version>1</release-version> | ||
<specification-version>1.71</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.openide.dialogs</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>7.46</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.openide.filesystems</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>9.14</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.openide.loaders</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>7.72</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.openide.nodes</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>7.50</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.openide.util</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>9.11</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.openide.util.lookup</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>8.37</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
<dependency> | ||
<code-name-base>org.openide.util.ui</code-name-base> | ||
<build-prerequisite/> | ||
<compile-dependency/> | ||
<run-dependency> | ||
<specification-version>9.12</specification-version> | ||
</run-dependency> | ||
</dependency> | ||
</module-dependencies> | ||
<test-dependencies> | ||
<test-type> | ||
<name>unit</name> | ||
<test-dependency> | ||
<code-name-base>org.netbeans.modules.nbjunit</code-name-base> | ||
<recursive/> | ||
<compile-dependency/> | ||
</test-dependency> | ||
<test-dependency> | ||
<code-name-base>org.netbeans.modules.projectapi.nb</code-name-base> | ||
<recursive/> | ||
<compile-dependency/> | ||
</test-dependency> | ||
</test-type> | ||
</test-dependencies> | ||
<public-packages/> | ||
</data> | ||
</configuration> | ||
</project> |
18 changes: 18 additions & 0 deletions
18
groovy/gradle.htmlui/src/org/netbeans/modules/gradle/htmlui/Bundle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
OpenIDE-Module-Name=DukeScript Gradle Project Wizard |
Binary file added
BIN
+796 Bytes
groovy/gradle.htmlui/src/org/netbeans/modules/gradle/htmlui/DukeHTML.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions
73
groovy/gradle.htmlui/src/org/netbeans/modules/gradle/htmlui/GradleArchetype.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.netbeans.modules.gradle.htmlui; | ||
|
||
import java.io.IOException; | ||
import java.util.Enumeration; | ||
import java.util.Map; | ||
import org.netbeans.api.templates.FileBuilder; | ||
import org.netbeans.api.templates.FileBuilder.Mode; | ||
import org.openide.filesystems.FileObject; | ||
import org.openide.filesystems.FileUtil; | ||
import org.openide.util.MapFormat; | ||
|
||
final class GradleArchetype { | ||
private final FileObject templates; | ||
private final FileObject projectFo; | ||
private final Map<String, Object> params; | ||
|
||
GradleArchetype(FileObject templates, FileObject projectFo, Map<String, Object> params) { | ||
this.templates = templates; | ||
this.projectFo = projectFo; | ||
this.params = params; | ||
} | ||
|
||
final void copyTemplates() throws IOException { | ||
MapFormat mf = new MapFormat(params); | ||
mf.setLeftBrace("${"); // NOI18N | ||
mf.setRightBrace("}"); // NOI18N | ||
Enumeration<? extends FileObject> en = templates.getChildren(true); | ||
while (en.hasMoreElements()) { | ||
FileObject template = en.nextElement(); | ||
if (!template.isData()) { | ||
continue; | ||
} | ||
String relativeParent = FileUtil.getRelativePath(templates, template.getParent()); | ||
Object packageAttr = template.getAttribute("package"); // NOI18N | ||
if (packageAttr instanceof String) { | ||
String packageName = mf.format(packageAttr).replace('.', '/'); | ||
relativeParent += "/" + packageName; | ||
} | ||
FileObject destinationFolder = FileUtil.createFolder(projectFo, relativeParent); | ||
|
||
FileObject previous = destinationFolder.getFileObject(template.getNameExt()); | ||
if (previous != null) { | ||
previous.delete(); | ||
} | ||
|
||
FileBuilder fb = new FileBuilder(template, destinationFolder); | ||
fb.withParameters(params); | ||
fb.defaultMode(Mode.COPY); | ||
|
||
FileObject copied = fb.build().iterator().next(); | ||
|
||
assert copied != null && copied.getNameExt().equals(template.getNameExt()) : "Created " + copied; | ||
} | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...radle.htmlui/src/org/netbeans/modules/gradle/htmlui/HtmlJavaApplicationProjectWizard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.netbeans.modules.gradle.htmlui; | ||
|
||
import org.netbeans.modules.gradle.spi.newproject.SimpleGradleWizardIterator; | ||
import org.netbeans.modules.gradle.spi.newproject.TemplateOperation; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.netbeans.api.project.Project; | ||
import org.netbeans.modules.gradle.api.NbGradleProject; | ||
import org.openide.WizardDescriptor; | ||
import org.openide.filesystems.FileObject; | ||
import org.openide.filesystems.FileUtil; | ||
import org.openide.loaders.TemplateWizard; | ||
import org.openide.util.Exceptions; | ||
import org.openide.util.NbBundle.Messages; | ||
|
||
@Messages("template.htmlUIProject=Java Frontend Application") | ||
public class HtmlJavaApplicationProjectWizard extends SimpleGradleWizardIterator { | ||
private static final String DEFAULT_LICENSE_TEMPLATE = "/Templates/Licenses/license-default.txt"; //NOI18N | ||
|
||
@Messages("LBL_FrontendApplicationProject=Java Frontend Application with Gradle") | ||
public HtmlJavaApplicationProjectWizard() { | ||
super(Bundle.LBL_FrontendApplicationProject(), initParams()); | ||
} | ||
|
||
private static Map<String, Object> initParams() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this method is a copy paste and does not really needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method is used on line 47, but the properties are likely useless: ee258eb |
||
Map<String, Object> params = new HashMap<>(); | ||
return params; | ||
} | ||
|
||
@Override | ||
protected List<? extends WizardDescriptor.Panel<WizardDescriptor>> createPanels() { | ||
return Collections.singletonList(createProjectAttributesPanel(null)); | ||
} | ||
|
||
@Override | ||
protected void collectOperations(TemplateOperation ops, Map<String, Object> params) { | ||
super.collectOperations(ops, params); | ||
String packageBase = (String) params.get(PROP_PACKAGE_BASE); | ||
String mainClassName = (String) params.get("mainClassName"); | ||
|
||
File projectDir = (File) params.get("projectDir"); | ||
|
||
File mainJava = (File) params.get(PROP_MAIN_JAVA_DIR); | ||
File packageDir = new File(mainJava, packageBase.replace('.', '/')); | ||
Map<String, Object> mainParams = new HashMap<>(params); | ||
mainParams.put("project", new DummyProject()); | ||
mainParams.put("package", packageBase); //NOI18N | ||
mainParams.put("name", mainClassName); //NOI18N | ||
|
||
FileObject folder = ((TemplateWizard)this.getData()).getTemplate().getPrimaryFile(); | ||
ops.addConfigureProject(projectDir, new CopyTree(folder, projectDir, mainParams)); | ||
} | ||
|
||
private static class CopyTree implements TemplateOperation.ProjectConfigurator { | ||
private final FileObject templateFolder; | ||
private final File projectDir; | ||
private final Map<String, Object> params; | ||
|
||
private CopyTree(FileObject templateFolder, File projectDir, Map<String, Object> params) { | ||
this.projectDir = projectDir; | ||
this.params = params; | ||
this.templateFolder = templateFolder; | ||
} | ||
|
||
@Override | ||
public void configure(Project project) { | ||
FileObject projectFo = FileUtil.toFileObject(projectDir); | ||
|
||
GradleArchetype ga = new GradleArchetype(templateFolder, projectFo, params); | ||
try { | ||
ga.copyTemplates(); | ||
} catch (IOException ex) { | ||
Exceptions.printStackTrace(ex); | ||
} finally { | ||
NbGradleProject.fireGradleProjectReload(project); | ||
} | ||
} | ||
} | ||
|
||
public static class DummyProject { | ||
public String getLicensePath() { | ||
return DEFAULT_LICENSE_TEMPLATE; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 could be quite confusing especially when this is in the main Gradle Project Wizard folder. At least if I'd like to do a Java Frontend Application, I would not think on bck2brwsr app on the first place (I'm sorry for that).
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 template is not about bck2brwsr. The main focus is DukeScript - e.g. combination of the best Java VM and portable frontend rendering. What exactly is the problem? The "Run" action? If so, it can be changed to do the same thing as "Debug".
The naming is consistent with the Maven category. There is a Java Frontend Application archetype in the Maven category which leads to the same/similar application, using the same libraries. Our intention is to deliver the same Java Frontend Application experience to Gradle users.
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.
Btw. there is also a way to run the application as Android application and as iOS application. They aren't advertised in the UI yet as it requires additional configuration of SDK, simulator, etc. We'd welcome coordinated support in this direction of generic Java Frontend Applications, but we think it is out of the scope of this PR.