Author: fbricon
Date: 2011-11-21 06:20:58 -0500 (Mon, 21 Nov 2011)
New Revision: 36474
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
Log:
JBIDE-10200: Add default maven profiles configuration to project examples
https://issues.jboss.org/browse/JBIDE-10200
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2011-11-21
10:52:56 UTC (rev 36473)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2011-11-21
11:20:58 UTC (rev 36474)
@@ -16,8 +16,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
/**
@@ -46,6 +44,7 @@
private ArchetypeModel archetypeModel = new ArchetypeModel();
private File file;
private IProjectExampleSite site;
+ private String defaultProfiles ="";
public Project() {
name=""; //$NON-NLS-1$
@@ -253,4 +252,13 @@
public void setFile(File file) {
this.file = file;
}
+
+ public String getDefaultProfiles() {
+ return defaultProfiles;
+ }
+
+ public void setDefaultProfiles(String defaultProfiles) {
+ this.defaultProfiles = defaultProfiles;
+ }
+
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2011-11-21
10:52:56 UTC (rev 36473)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2011-11-21
11:20:58 UTC (rev 36474)
@@ -264,7 +264,7 @@
parseFixes(project, child);
}
- if (nodeName.equals("category")) { //$NON-NLS-1$
+ else if (nodeName.equals("category")) { //$NON-NLS-1$
String value = getContent(child);
boolean found = false;
for (Category cat : list) {
@@ -281,29 +281,29 @@
}
project.setCategory(category);
}
- if (nodeName.equals(NAME)) {
+ else if (nodeName.equals(NAME)) {
project.setName(getContent(child));
}
- if (nodeName.equals("shortDescription")) { //$NON-NLS-1$
+ else if (nodeName.equals("shortDescription")) { //$NON-NLS-1$
project
.setShortDescription(getContent(child));
}
- if (nodeName.equals("description")) { //$NON-NLS-1$
+ else if (nodeName.equals("description")) { //$NON-NLS-1$
project.setDescription(getContent(child));
}
- if (nodeName.equals(URL)) {
+ else if (nodeName.equals(URL)) {
project.setUrl(getContent(child));
}
- if (nodeName.equals("perspectiveId")) { //$NON-NLS-1$
+ else if (nodeName.equals("perspectiveId")) { //$NON-NLS-1$
project.setPerspectiveId(getContent(child));
}
- if (nodeName.equals("importType")) { //$NON-NLS-1$
+ else if (nodeName.equals("importType")) { //$NON-NLS-1$
project.setImportType(getContent(child));
}
- if (nodeName.equals("importTypeDescription")) { //$NON-NLS-1$
+ else if (nodeName.equals("importTypeDescription")) { //$NON-NLS-1$
project.setImportTypeDescription(getContent(child));
}
- if (nodeName.equals("size")) { //$NON-NLS-1$
+ else if (nodeName.equals("size")) { //$NON-NLS-1$
long size = 0;
try {
size = new Long(getContent(child));
@@ -311,7 +311,7 @@
}
project.setSize(size);
}
- if (nodeName.equals("included-projects")) { //$NON-NLS-1$
+ else if (nodeName.equals("included-projects")) { //$NON-NLS-1$
String includedProjects = getContent(child);
if (includedProjects != null) {
includedProjects = includedProjects
@@ -325,7 +325,10 @@
project.setIncludedProjects(projectList);
}
}
- if (nodeName.equals("welcome")) { //$NON-NLS-1$
+ else if (nodeName.equals("defaultMavenProfiles")) { //$NON-NLS-1$
+ project.setDefaultProfiles(getContent(child));
+ }
+ else if (nodeName.equals("welcome")) { //$NON-NLS-1$
project.setWelcome(true);
String attribute = child.getAttribute("type"); //$NON-NLS-1$
if (attribute != null && CHEATSHEETS.equals(attribute.trim())) {
@@ -341,7 +344,7 @@
project.setWelcomeURL(attribute.trim());
}
}
- if (nodeName.equals("mavenArchetype")) { //$NON-NLS-1$
+ else if (nodeName.equals("mavenArchetype")) { //$NON-NLS-1$
parseMavenArchetype(project, child);
}
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java 2011-11-21
10:52:56 UTC (rev 36473)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java 2011-11-21
11:20:58 UTC (rev 36474)
@@ -124,11 +124,11 @@
return projects;
}
- importMavenProjects(destination);
+ importMavenProjects(destination, projectDescription);
return projects;
}
- private void importMavenProjects(final File destination) {
+ private void importMavenProjects(final File destination, final Project
projectDescription) {
Job job = new ProjectExamplesJob("Importing Maven projects") {
public IStatus runInWorkspace(IProgressMonitor monitor) {
setProperty(IProgressConstants.ACTION_PROPERTY,
@@ -144,7 +144,11 @@
addMavenProjects(infos, mavenProjects);
final List<IProject> existingProjects = new ArrayList<IProject>();
ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration();
- for(MavenProjectInfo info:infos) {
+ String profiles = projectDescription.getDefaultProfiles();
+ if (profiles != null && profiles.trim().length() > 0) {
+ importConfiguration.getResolverConfiguration().setActiveProfiles(profiles);
+ }
+ for(MavenProjectInfo info:infos) {
String projectName = getProjectName(info, importConfiguration);
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (project != null && project.exists()) {
@@ -175,7 +179,7 @@
return Status.CANCEL_STATUS;
}
}
- plugin.getProjectConfigurationManager().importProjects(
+ MavenPlugin.getProjectConfigurationManager().importProjects(
infos, importConfiguration, monitor);
} catch (CoreException ex) {
MavenProjectExamplesActivator.log(ex, "Projects imported with errors");
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2011-11-21
10:52:56 UTC (rev 36473)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2011-11-21
11:20:58 UTC (rev 36474)
@@ -99,6 +99,7 @@
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
+
return false;
}
@@ -109,6 +110,10 @@
public void addPages() {
configuration = new ProjectImportConfiguration();
+ String profiles = projectDescription.getDefaultProfiles();
+ if (profiles != null && profiles.trim().length() > 0) {
+ configuration.getResolverConfiguration().setActiveProfiles(profiles);
+ }
wizardPage = new ArchetypeExamplesWizardPage(configuration, projectDescription);
addPage(wizardPage);
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-11-21
10:52:56 UTC (rev 36473)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2011-11-21
11:20:58 UTC (rev 36474)
@@ -63,6 +63,7 @@
@Override
public void createControl(Composite parent) {
+ long start = System.currentTimeMillis();
super.createControl(parent);
Archetype archetype = new Archetype();
ArchetypeModel archetypeModel = projectDescription.getArchetypeModel();
@@ -113,6 +114,9 @@
groupIdCombo.setText(groupId);
versionCombo.setText(version);
packageCombo.setText(javaPackage);
+
+ long stop = System.currentTimeMillis();
+ System.err.println("Create controls took " + (stop-start) + "
ms");
}
public Archetype getArchetype() {
@@ -160,10 +164,12 @@
}
} catch(UnknownArchetype e) {
MavenProjectExamplesActivator.log(e);
- //TODO don't swallow exceptions
+ e.printStackTrace();
+ //TODO don't swallow exceptions
} catch(CoreException ex) {
//TODO don't swallow exceptions
MavenProjectExamplesActivator.log(ex);
+ ex.printStackTrace();
} finally {
monitor.done();
}
@@ -190,7 +196,7 @@
private Artifact downloadArchetype(String groupId, String artifactId,
String version, ArtifactRepository archetypeRepository,
List<ArtifactRepository> repositories) throws CoreException {
-
+ long start = System.currentTimeMillis();
IMaven maven = MavenPlugin.getMaven();
ArrayList<ArtifactRepository> repos = new
ArrayList<ArtifactRepository>();
if (archetypeRepository != null) {
@@ -199,7 +205,10 @@
repos.addAll(maven.getArtifactRepositories()); // see
org.apache.maven.archetype.downloader.DefaultDownloader#download
IProgressMonitor nullProgressMonitor = new NullProgressMonitor();
maven.resolve(groupId, artifactId, version, "pom", null, repos,
nullProgressMonitor); //$NON-NLS-1$
- return maven.resolve(groupId, artifactId, version, "jar", null, repos,
nullProgressMonitor); //$NON-NLS-1$
+ Artifact a = maven.resolve(groupId, artifactId, version, "jar", null,
repos, nullProgressMonitor); //$NON-NLS-1$
+ long stop = System.currentTimeMillis();
+ System.err.println("download took " + (stop-start) + " ms");
+ return a;
}
}