Skip to content

Commit

Permalink
Merge pull request #4150 from apache/delivery
Browse files Browse the repository at this point in the history
Sync delivery to release140 for 14-rc6
  • Loading branch information
ebarboni authored May 30, 2022
2 parents 0bf8e0f + cc14a92 commit c4f2d87
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,27 +255,29 @@ private static void setMainClass(Map<Object, Object> properties, FileObject fo)
POMModel model = POMModelFactory.getDefault().getModel(modelSource);
org.netbeans.modules.maven.model.pom.Project root = model.getProject();
if (root != null) {
if (model.startTransaction()) {
try {
org.netbeans.modules.maven.model.pom.Properties props = root.getProperties();
if (props == null) {
props = model.getFactory().createProperties();
root.setProperties(props);
}
String packageName = (String) properties.get(TemplateUtils.PARAM_PACKAGE);
String mainClass = (String) properties.get(TemplateUtils.PARAM_MAIN_CLASS_NAME);
if (mainClass == null || mainClass.isEmpty()) {
mainClass = "App"; // NOI18N
}
if (packageName != null && !packageName.isEmpty()) {
mainClass = packageName + '.' + mainClass;
}
props.setProperty("exec.mainClass", mainClass); // NOI18N
} finally {
model.endTransaction();
if (model.getProject().getPackaging() == null || "jar".equals(model.getProject().getPackaging())) {
if (model.startTransaction()) {
try {
Utilities.saveChanges(model);
} catch (IOException ex) {}
org.netbeans.modules.maven.model.pom.Properties props = root.getProperties();
if (props == null) {
props = model.getFactory().createProperties();
root.setProperties(props);
}
String packageName = (String) properties.get(TemplateUtils.PARAM_PACKAGE);
String mainClass = (String) properties.get(TemplateUtils.PARAM_MAIN_CLASS_NAME);
if (mainClass == null || mainClass.isEmpty()) {
mainClass = "App"; // NOI18N
}
if (packageName != null && !packageName.isEmpty()) {
mainClass = packageName + '.' + mainClass;
}
props.setProperty("exec.mainClass", mainClass); // NOI18N
} finally {
model.endTransaction();
try {
Utilities.saveChanges(model);
} catch (IOException ex) {}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ protected FileBuilder builder(ProgressHandle h) throws IOException {

return new FileBuilder(w.getTemplate().getPrimaryFile(), w.getTargetFolder().getPrimaryFile().getParent()).
param(TemplateUtils.PARAM_PACKAGE, (String) wiz.getProperty("package")).
param(TemplateUtils.PARAM_PACKAGING, (String) this.packaging).
defaultMode(FileBuilder.Mode.COPY).
name(w.getTargetName()).
useLookup(Lookups.fixed(h));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,18 @@ protected List<FileObject> createProjectContents(FileObject target, CreateDescri
params.put("projecName", cd.getName());
params.put("packagePath", pi.packageName == null ? "" : pi.packageName.replace('.', '/')); // NOI18N

String mainName;
if (!params.containsKey("mainClassName")) { // NOI18N
String derived = deriveClassName(pi.artifactId);
if (BaseUtilities.isJavaIdentifier(derived)) {
mainName = derived;
} else {
mainName = "App"; // NOI18N
String packaging = cd.getValue(TemplateUtils.PARAM_PACKAGING);
if (packaging == null || "jar".equals(packaging)) { // NOI18N
String mainName;
if (!params.containsKey("mainClassName")) { // NOI18N
String derived = deriveClassName(pi.artifactId);
if (BaseUtilities.isJavaIdentifier(derived)) {
mainName = derived;
} else {
mainName = "App"; // NOI18N
}
params.put("mainClassName", mainName); // NOI18N
}
params.put("mainClassName", mainName); // NOI18N
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
*
* @author mkleint
*/
@TemplateRegistration(folder=ArchetypeWizards.TEMPLATE_FOLDER, position=980, displayName="#LBL_Maven_POM_Archetype", iconBase="org/netbeans/modules/maven/resources/Maven2Icon.gif", description="pom-root.html")
@TemplateRegistration(
displayName="#LBL_Maven_POM_Archetype",
iconBase="org/netbeans/modules/maven/resources/Maven2Icon.gif",
description="pom-root.html",
folder=ArchetypeWizards.TEMPLATE_FOLDER,
position=980,
createHandlerClass = IDENativeTemplateHandler.class
)
@NbBundle.Messages("LBL_Maven_POM_Archetype=POM Project")
public class PomJavaNativeMWI extends IDENativeMavenWizardIterator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,23 @@ public Reference<Object> poll() {
}

@Override
public Reference<Object> remove(long timeout) throws IllegalArgumentException, InterruptedException {
throw new InterruptedException();
public Reference<? extends Object> remove(long timeout) throws IllegalArgumentException, InterruptedException {
if (timeout < 0) {
throw new IllegalArgumentException("Negative timeout value");
} else if (Thread.currentThread() != Daemon.running) {
throw new InterruptedException();
}

return super.remove(timeout);
}

@Override
public Reference<Object> remove() throws InterruptedException {
throw new InterruptedException();
}

final Reference<? extends Object> removeSuper() throws InterruptedException {
return super.remove(0);
public Reference<? extends Object> remove() throws InterruptedException {
if (Thread.currentThread() != Daemon.running) {
throw new InterruptedException();
}

return super.remove();
}
}

Expand Down Expand Up @@ -112,7 +118,7 @@ public void run() {
if (impl == null) {
return;
}
Reference<?> ref = impl.removeSuper();
Reference<?> ref = impl.remove();
LOGGER.log(Level.FINE, "Got dequeued reference {0}", new Object[] { ref });
if (!(ref instanceof Runnable)) {
LOGGER.log(Level.WARNING, "A reference not implementing runnable has been added to the Utilities.activeReferenceQueue(): {0}", ref.getClass());
Expand All @@ -131,9 +137,8 @@ public void run() {
// to allow GC
ref = null;
}
} catch (InterruptedException ex) {
// Can happen during VM shutdown, it seems. Ignore.
continue;
} catch (InterruptedException ignored) {
// Can happen during VM shutdown, it seems.
}
}
}
Expand Down

0 comments on commit c4f2d87

Please sign in to comment.