Author: fbricon
Date: 2012-05-11 13:40:41 -0400 (Fri, 11 May 2012)
New Revision: 40959
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/MavenArtifactHelper.java
Log:
JBIDE-11684 : fixed local repo path and message sent when EAP repo is not found
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties 2012-05-11
16:52:29 UTC (rev 40958)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties 2012-05-11
17:40:41 UTC (rev 40959)
@@ -5,6 +5,6 @@
ArchetypeExamplesWizardFirstPage_ProjectName_Label=Project name
ArchetypeExamplesWizardFirstPage_Target_Runtime_Label=Target Runtime
ArchetypeExamplesWizardFirstPage_Title=Create a new Java EE project
-ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo={0} cannot be found. This
indicates you do not have access to a JBoss Enterprise Maven repository.\nThis can cause
build problems. Follow this <a
href\="http\://community.jboss.org/wiki/SettingUpTheJBossEnterpriseR...
for more details.
+ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo=A *-redhat version of {0}
cannot be found. This indicates you do not have access to a JBoss Enterprise Maven
repository.\nThis can cause build problems. Follow this <a
href\="http\://community.jboss.org/wiki/SettingUpTheJBossEnterpriseR...
for more details.
ArchetypeExamplesWizardFirstPage_Unresolved_WFK_Repo=The enterprise version of this
project has a dependency on {0} which cannot be found. This indicates you do not have
access to a JBoss WFK Maven repository or that repository is incomplete.\nThis can cause
build problems. Follow this <a
href\="http\://community.jboss.org/wiki/SettingUpTheJBossEnterpriseR...
for more details.
ArchetypeExamplesWizardFirstPage_Error_Package=Invalid package name
\ No newline at end of file
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/MavenArtifactHelper.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/MavenArtifactHelper.java 2012-05-11
16:52:29 UTC (rev 40958)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/MavenArtifactHelper.java 2012-05-11
17:40:41 UTC (rev 40959)
@@ -42,16 +42,16 @@
public class MavenArtifactHelper {
- //private static final DependencyKey ENTERPRISE_JBOSS_SPEC =
DependencyKey.fromPortableString("org.jboss.spec:jboss-javaee-web-6.0:pom:3.0.0.Beta1-redhat-1::");
//$NON-NLS-1$
+ private static final String JBOSS_SPEC =
"org.jboss.spec:jboss-javaee-web-6.0"; //$NON-NLS-1$
- private static final String COORDS =
"org.jboss.spec:jboss-javaee-web-6.0:[0,)"; //$NON-NLS-1$
+ private static final String COORDS = JBOSS_SPEC+":[0,)"; //$NON-NLS-1$
/**
* Checks if the EAP repository is available
*
* @return true if org.jboss.spec:jboss-javaee-web-6.0:pom:*redhat* can be resolved
*/
public static boolean isEnterpriseRepositoryAvailable() {
- boolean isRepoAvailable = artifactExists(COORDS);
+ boolean isRepoAvailable = redHatArtifactExists(COORDS);
return isRepoAvailable;
}
@@ -87,7 +87,7 @@
if (!isEnterpriseRepositoryAvailable()) {
return new Status(IStatus.ERROR,
MavenProjectExamplesActivator.PLUGIN_ID,
- NLS.bind(Messages.ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo,
COORDS));
+ NLS.bind(Messages.ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo,
JBOSS_SPEC));
}
if (project != null) {
Set<String> requirements = project.getEssentialEnterpriseDependencyGavs();
@@ -105,7 +105,7 @@
return Status.OK_STATUS;
}
- private static boolean artifactExists(String coords) {
+ private static boolean redHatArtifactExists(String coords) {
RepositorySystem system;
try {
system = new DefaultPlexusContainer()
@@ -115,15 +115,15 @@
return false;
}
MavenRepositorySystemSession session = new MavenRepositorySystemSession();
- String localRepoHome = System.getProperty("user.home") //$NON-NLS-1$
- + Path.SEPARATOR + ".m2" + Path.SEPARATOR + "repository";
//$NON-NLS-1$ //$NON-NLS-2$
+ IMaven maven = MavenPlugin.getMaven();
+ String localRepoHome = maven.getLocalRepositoryPath();
LocalRepository localRepo = new LocalRepository(localRepoHome);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
- org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(coords);
+
VersionRangeRequest rangeRequest = new VersionRangeRequest();
- rangeRequest.setArtifact(artifact);
+ rangeRequest.setArtifact( new DefaultArtifact(coords));
+
List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>();
- IMaven maven = MavenPlugin.getMaven();
try {
repos.addAll(maven.getArtifactRepositories(false));
} catch (CoreException e) {
@@ -135,8 +135,7 @@
rangeRequest.addRepository(remoteRepo);
}
try {
- VersionRangeResult result = system.resolveVersionRange(
- session, rangeRequest);
+ VersionRangeResult result = system.resolveVersionRange( session, rangeRequest);
List<Version> versions = result.getVersions();
for (Version version:versions) {
if (version != null && version.toString().contains("redhat")) {
//$NON-NLS-1$