Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4 from jGauravGupta/PAYARA2-2856
Browse files Browse the repository at this point in the history
PAYARA2-2856 NetBeans Plugin dependencies version upgrade and release v1.3
  • Loading branch information
jGauravGupta authored Jun 18, 2018
2 parents 558626c + 6a34425 commit e7f956c
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 33 deletions.
2 changes: 1 addition & 1 deletion payara.common/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.payara.common
OpenIDE-Module-Layer: org/netbeans/modules/payara/common/layer.xml
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/payara/common/Bundle.properties
OpenIDE-Module-Specification-Version: 1.2
OpenIDE-Module-Specification-Version: 1.3

2 changes: 1 addition & 1 deletion payara.eecommon/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.payara.eecommon
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/payara/eecommon/Bundle.properties
OpenIDE-Module-Specification-Version: 1.2
OpenIDE-Module-Specification-Version: 1.3

2 changes: 1 addition & 1 deletion payara.javaee/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.payara.javaee
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/payara/javaee/Bundle.properties
OpenIDE-Module-Specification-Version: 1.2
OpenIDE-Module-Specification-Version: 1.3
OpenIDE-Module-Layer: org/netbeans/modules/payara/javaee/layer.xml

2 changes: 1 addition & 1 deletion payara.micro/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.payara.micro
OpenIDE-Module-Layer: org/netbeans/modules/fish/payara/micro/layer.xml
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/fish/payara/micro/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
OpenIDE-Module-Specification-Version: 1.3

2 changes: 1 addition & 1 deletion payara.micro/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>9.10.2</specification-version>
<specification-version>9.10.1</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class Constants {

public static final String ARCHETYPE_GROUP_ID = "fish.payara.maven.archetypes";
public static final String ARCHETYPE_ARTIFACT_ID = "payara-micro-maven-archetype";
public static final String ARCHETYPE_VERSION = "1.0";
public static final String ARCHETYPE_VERSION = "1.0.1";
public static final String ARCHETYPE_REPOSITORY = "https://oss.sonatype.org/content/repositories/snapshots";


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
import static java.util.stream.Collectors.toSet;
import javax.swing.SwingUtilities;
import javax.xml.namespace.QName;
Expand Down Expand Up @@ -84,6 +85,8 @@ public class POMManager {

private static final RequestProcessor RP = new RequestProcessor("Maven loading");

private BiFunction<Xpp3Dom, POMExtensibilityElement, Boolean> extensionOverrideFilter;

public POMManager(Project project){
this(project, false);
}
Expand Down Expand Up @@ -178,6 +181,10 @@ public void addProperties(String profile, java.util.Properties prop) {
}
}

public void setExtensionOverrideFilter(BiFunction<Xpp3Dom, POMExtensibilityElement, Boolean> extensionOverrideFilter) {
this.extensionOverrideFilter = extensionOverrideFilter;
}

public static boolean isMavenProject(Project project) {
return project.getLookup().lookup(NbMavenProjectImpl.class) != null;
}
Expand Down Expand Up @@ -334,7 +341,9 @@ private void loadDom(Xpp3Dom source, POMComponent target) {
Optional<POMExtensibilityElement> targetElementOptioal = target.getExtensibilityElements()
.stream()
.filter(targetElement -> StringUtils.equals(targetElement.getQName().getLocalPart(), childDOM.getName()))
.filter(targetElement -> extensionOverrideFilter == null || extensionOverrideFilter.apply(childDOM, targetElement))
.findAny();

POMExtensibilityElement element;
if (targetElementOptioal.isPresent()) {
element = targetElementOptioal.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.netbeans.modules.fish.payara.micro.project.ProjectHookImpl;
import org.netbeans.modules.fish.payara.micro.project.ui.PayaraMicroDescriptor;
import org.netbeans.modules.maven.NbMavenProjectImpl;
import org.netbeans.modules.maven.model.pom.POMExtensibilityElement;
import org.netbeans.spi.project.ui.templates.support.Templates;
import org.openide.WizardDescriptor;
import org.openide.util.NbBundle;
Expand All @@ -58,6 +59,30 @@ public final class MicroPluginWizardDescriptor implements WizardDescriptor.Insta
private Project project;

private List<WizardDescriptor.Panel<WizardDescriptor>> panels;

public static void updateMicroMavenPlugin(Project project, String payaraMicroVersion, String autoBindHttp) throws IOException {
Map<String, Object> params = new HashMap<>();
params.put("autoBindHttp", autoBindHttp);
params.put("payaraMicroVersion", payaraMicroVersion);

try (Reader sourceReader = new InputStreamReader(loadResource("org/netbeans/modules/fish/payara/micro/plugin/resources/pom.xml.ftl"))) {
try (Reader targetReader = new StringReader(expandTemplate(sourceReader, params))) {
POMManager pomManager = new POMManager(targetReader, project);
pomManager.setExtensionOverrideFilter((source, target) -> {
if ("option".equalsIgnoreCase(source.getName())) {
for (POMExtensibilityElement element : target.getExtensibilityElements()) {
if ("key".equals(element.getQName().getLocalPart())) {
return source.getChild("key").getValue().equals(element.getElementText());
}
}
}
return true;
});
pomManager.commit();
pomManager.reload();
}
}
}

@Override
public void initialize(WizardDescriptor descriptor) {
Expand All @@ -81,23 +106,13 @@ public void initialize(WizardDescriptor descriptor) {
@Override
public Set instantiate() throws IOException {
String payaraMicroVersion = (String) descriptor.getProperty(PROP_PAYARA_MICRO_VERSION);
String autoBindHTTP = (String) descriptor.getProperty(PROP_AUTO_BIND_HTTP);
String autoBindHttp = (String) descriptor.getProperty(PROP_AUTO_BIND_HTTP);

Map<String, Object> params = new HashMap<>();
params.put("autoBindHttp", autoBindHTTP);
params.put("payaraMicroVersion", payaraMicroVersion);
updateMicroMavenPlugin(project, payaraMicroVersion, autoBindHttp);

try (Reader sourceReader = new InputStreamReader(loadResource("org/netbeans/modules/fish/payara/micro/plugin/resources/_pom.xml"))) {
try (Reader targetReader = new StringReader(expandTemplate(sourceReader, params))) {
POMManager pomManager = new POMManager(targetReader, project);
pomManager.commit();
pomManager.reload();

ProjectHookImpl projectHookImpl = new ProjectHookImpl(project);
projectHookImpl.initMicroProject(true);
project.getLookup().lookup(NbMavenProjectImpl.class).fireProjectReload();
}
}
ProjectHookImpl projectHookImpl = new ProjectHookImpl(project);
projectHookImpl.initMicroProject(true);
project.getLookup().lookup(NbMavenProjectImpl.class).fireProjectReload();
return Collections.emptySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@
<plugin>
<groupId>fish.payara.maven.plugins</groupId>
<artifactId>payara-micro-maven-plugin</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>1.0.1</version>
<configuration>
<payaraVersion>${r"${version.payara.micro}"}</payaraVersion>
<artifactItem>
<groupId>fish.payara.extras</groupId>
<artifactId>payara-micro</artifactId>
<version>${r"${version.payara.micro}"}</version>
</artifactItem>
<deployWar>false</deployWar>
<commandLineOptions>
<#if autoBindHttp == "true">
<option>
<key>--autoBindHttp</key>
<value>${autoBindHttp}</value>
</option>
</#if>
<option>
<key>--deploy</key>
<value>${r"${project.build.directory}"}/${r"${project.build.finalName}"}</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
*/
package org.netbeans.modules.fish.payara.micro.project;

import org.netbeans.api.project.Project;

/**
*
* @author Gaurav Gupta <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import static org.netbeans.modules.fish.payara.micro.Constants.PROP_PACKAGE;
import static org.netbeans.modules.fish.payara.micro.Constants.PROP_PAYARA_MICRO_VERSION;
import static org.netbeans.modules.fish.payara.micro.Constants.PROP_VERSION;
import static org.netbeans.modules.fish.payara.micro.plugin.MicroPluginWizardDescriptor.updateMicroMavenPlugin;
import org.netbeans.modules.maven.api.archetype.Archetype;
import org.netbeans.modules.maven.api.archetype.ArchetypeWizards;
import org.netbeans.modules.maven.api.archetype.ProjectInfo;
Expand Down Expand Up @@ -92,12 +93,13 @@ public Set<FileObject> instantiate() throws IOException {
(String) descriptor.getProperty(PROP_PACKAGE)
);
String payaraMicroVersion = (String) descriptor.getProperty(PROP_PAYARA_MICRO_VERSION);
String autoBindHttp = (String) descriptor.getProperty(PROP_AUTO_BIND_HTTP);
Archetype archetype = createMojoArchetype();

Map<String, String> properties = new HashMap<>();
properties.put(PROP_PAYARA_MICRO_VERSION, payaraMicroVersion);
properties.put(PROP_JAVA_EE_VERSION, VersionRepository.getInstance().getJavaEEVersion(payaraMicroVersion));
properties.put(PROP_AUTO_BIND_HTTP, (String) descriptor.getProperty(PROP_AUTO_BIND_HTTP));
properties.put(PROP_AUTO_BIND_HTTP, autoBindHttp);

ArchetypeWizards.logUsage(archetype.getGroupId(), archetype.getArtifactId(), archetype.getVersion());

Expand All @@ -111,6 +113,7 @@ public Set<FileObject> instantiate() throws IOException {
continue;
}
MavenProjectSupport.changeServer(project, true);
updateMicroMavenPlugin(project, payaraMicroVersion, autoBindHttp);
}

return projects;
Expand All @@ -121,7 +124,6 @@ private Archetype createMojoArchetype() {
archetype.setGroupId(ARCHETYPE_GROUP_ID);
archetype.setArtifactId(ARCHETYPE_ARTIFACT_ID);
archetype.setVersion(ARCHETYPE_VERSION);
// archetype.setRepository(ARCHETYPE_REPOSITORY);
return archetype;
}

Expand Down
2 changes: 1 addition & 1 deletion payara.tooling/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.payara.tooling
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/payara/tooling/Bundle.properties
OpenIDE-Module-Specification-Version: 1.2
OpenIDE-Module-Specification-Version: 1.3

0 comments on commit e7f956c

Please sign in to comment.