Skip to content

Commit

Permalink
[NETBEANSINFRA-6] get latest archetype from maven repo (apache#1999)
Browse files Browse the repository at this point in the history
* [NETBEANS-3332] Get the latest nbm-archetype and netbeans-platform-app-archetype versions from the maven repository.
  • Loading branch information
oyarzun authored Mar 7, 2020
1 parent 276dbba commit 501ddbe
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import static org.netbeans.modules.maven.apisupport.Bundle.*;
import static org.netbeans.modules.maven.apisupport.MavenNbModuleImpl.APACHE_SNAPSHOT_REPO_ID;
import org.netbeans.modules.maven.embedder.EmbedderFactory;
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
import org.netbeans.spi.project.ui.support.CommonProjectActions;

public class NbmWizardIterator implements WizardDescriptor.BackgroundInstantiatingIterator<WizardDescriptor> {
Expand Down Expand Up @@ -113,7 +115,21 @@ private String[] createSteps() {
LBL_CreateProjectStepNbm()
};
}


private static void getLatestArchetypeVersion(Archetype archetype) {
RepositoryQueries.Result<NBVersionInfo> versionsResult = RepositoryQueries.getVersionsResult(archetype.getGroupId(), archetype.getArtifactId(), null);

if (versionsResult.isPartial()) {
versionsResult.waitForSkipped();
}

// Versions are sorted in descending order
List<NBVersionInfo> results = versionsResult.getResults();
if (!results.isEmpty()) {
archetype.setVersion(results.get(0).getVersion());
}
}

@Override
public Set<FileObject> instantiate() throws IOException {
ProjectInfo vi = new ProjectInfo((String) wiz.getProperty("groupId"), (String) wiz.getProperty("artifactId"), (String) wiz.getProperty("version"), (String) wiz.getProperty("package")); //NOI18N
Expand All @@ -127,10 +143,11 @@ public Set<FileObject> instantiate() throws IOException {
Map<String,String> additional = Collections.singletonMap("netbeansVersion", version); // NOI18N

if (archetype == NB_MODULE_ARCH) {
getLatestArchetypeVersion(NB_MODULE_ARCH);
NBMNativeMWI.instantiate(vi, projFile, version, Boolean.TRUE.equals(wiz.getProperty(OSGIDEPENDENCIES)), null);

} else {

getLatestArchetypeVersion(NB_APP_ARCH);
ArchetypeWizards.createFromArchetype(projFile, vi, archetype, additional, true);
List<ModelOperation<POMModel>> opers = new ArrayList<ModelOperation<POMModel>>();
if (Boolean.TRUE.equals(wiz.getProperty(OSGIDEPENDENCIES))) {
Expand Down

0 comments on commit 501ddbe

Please sign in to comment.