Author: fbricon
Date: 2012-05-10 09:17:28 -0400 (Thu, 10 May 2012)
New Revision: 40911
Added:
trunk/maven/features/org.jboss.tools.maven.jdt.feature/
trunk/maven/features/org.jboss.tools.maven.jdt.feature/.project
trunk/maven/features/org.jboss.tools.maven.jdt.feature/build.properties
trunk/maven/features/org.jboss.tools.maven.jdt.feature/feature.properties
trunk/maven/features/org.jboss.tools.maven.jdt.feature/feature.xml
trunk/maven/features/org.jboss.tools.maven.jdt.feature/license.html
trunk/maven/features/org.jboss.tools.maven.jdt.feature/pom.xml
trunk/maven/features/org.jboss.tools.maven.jdt.feature/sourceTemplateFeature/
trunk/maven/features/org.jboss.tools.maven.jdt.feature/sourceTemplateFeature/.gitkeep
trunk/maven/plugins/org.jboss.tools.maven.jdt/
trunk/maven/plugins/org.jboss.tools.maven.jdt/.classpath
trunk/maven/plugins/org.jboss.tools.maven.jdt/.project
trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/
trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/org.eclipse.jdt.core.prefs
trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/org.eclipse.m2e.core.prefs
trunk/maven/plugins/org.jboss.tools.maven.jdt/META-INF/
trunk/maven/plugins/org.jboss.tools.maven.jdt/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.jdt/about.html
trunk/maven/plugins/org.jboss.tools.maven.jdt/about.ini
trunk/maven/plugins/org.jboss.tools.maven.jdt/about.mappings
trunk/maven/plugins/org.jboss.tools.maven.jdt/about.properties
trunk/maven/plugins/org.jboss.tools.maven.jdt/build.properties
trunk/maven/plugins/org.jboss.tools.maven.jdt/jboss_about.png
trunk/maven/plugins/org.jboss.tools.maven.jdt/lifecycle-mapping-metadata.xml
trunk/maven/plugins/org.jboss.tools.maven.jdt/plugin.properties
trunk/maven/plugins/org.jboss.tools.maven.jdt/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.jdt/pom.xml
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/MavenJdtActivator.java
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/ClasspathHelpers.java
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibProjectConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesContainer.java
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesContainerInitializer.java
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesManager.java
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/JarFilter.java
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/xpl/
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/xpl/MavenClasspathContainerSaveHelper.java
Modified:
trunk/maven/features/pom.xml
trunk/maven/plugins/pom.xml
trunk/maven/site/category.xml
Log:
JBIDE-11738 : Solve/workaround the issue of needing endorsed libraries on Java 6
https://issues.jboss.org/browse/JBIDE-11738
Added: trunk/maven/features/org.jboss.tools.maven.jdt.feature/.project
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jdt.feature/.project
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jdt.feature/.project 2012-05-10 13:17:28
UTC (rev 40911)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.maven.jdt.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
Added: trunk/maven/features/org.jboss.tools.maven.jdt.feature/build.properties
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jdt.feature/build.properties
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jdt.feature/build.properties 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,3 @@
+bin.includes = feature.xml,\
+ license.html,\
+ feature.properties
Added: trunk/maven/features/org.jboss.tools.maven.jdt.feature/feature.properties
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jdt.feature/feature.properties
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jdt.feature/feature.properties 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,53 @@
+###############################################################################
+# Copyright (c) 2010-2012 Red Hat, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+#
http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# JBoss by Red Hat - Initial implementation.
+##############################################################################
+# feature.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=JBoss Maven Endorsed Libraries configurator
+
+# "providerName" property - name of the company that provides the feature
+providerName=JBoss by Red Hat
+
+# "updateSiteName" property - label for the update site
+updateSiteName=JBossTools Update Site
+
+# "description" property - description of the feature
+description=This feature provides additional m2e support for Endorsed Libraries
+
+# "copyright" property - text of the "Feature Update Copyright"
+copyright=Copyright (c) 2010-2012 Red Hat, Inc. and others.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http\://www.eclipse.org/legal/epl-v10.html\n\nContributors\:\n\
+JBoss by Red Hat - Initial implementation.
+ ############### end of copyright property ####################################
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# START NON-TRANSLATABLE
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=Red Hat, Inc. licenses these features and plugins to you under \
+certain open source licenses (or aggregations of such licenses), which \
+in a particular case may include the Eclipse Public License, the GNU \
+Lesser General Public License, and/or certain other open source \
+licenses. For precise licensing details, consult the corresponding \
+source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive, \
+Raleigh NC 27606 USA.
+# END NON-TRANSLATABLE
+########### end of license property ##########################################
Added: trunk/maven/features/org.jboss.tools.maven.jdt.feature/feature.xml
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jdt.feature/feature.xml
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jdt.feature/feature.xml 2012-05-10 13:17:28
UTC (rev 40911)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.jboss.tools.maven.jdt.feature"
+ label="%featureName"
+ version="1.3.0.qualifier"
+ provider-name="%providerName"
+ plugin="org.jboss.tools.maven.jdt">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <requires>
+ <import feature="org.eclipse.m2e.feature" version="0.13.0"
match="greaterOrEqual"/>
+ </requires>
+
+ <plugin
+ id="org.jboss.tools.maven.jdt"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
Added: trunk/maven/features/org.jboss.tools.maven.jdt.feature/license.html
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jdt.feature/license.html
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jdt.feature/license.html 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+
+<body>
+<p>Red Hat, Inc. licenses these features and plugins to you under
+certain open source licenses (or aggregations of such licenses), which
+in a particular case may include the Eclipse Public License, the GNU
+Lesser General Public License, and/or certain other open source
+licenses. For precise licensing details, consult the corresponding
+source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive,
+Raleigh NC 27606 USA.
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/maven/features/org.jboss.tools.maven.jdt.feature/pom.xml
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jdt.feature/pom.xml
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jdt.feature/pom.xml 2012-05-10 13:17:28 UTC
(rev 40911)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools.maven</groupId>
+ <artifactId>features</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.maven.features</groupId>
+ <artifactId>org.jboss.tools.maven.jdt.feature</artifactId>
+
+ <packaging>eclipse-feature</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho.extras</groupId>
+ <artifactId>tycho-source-feature-plugin</artifactId>
+ <version>${tychoExtrasVersion}</version>
+ <executions>
+ <execution>
+ <id>source-feature</id>
+ <phase>package</phase>
+ <goals>
+ <goal>source-feature</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-plugin</artifactId>
+ <version>${tychoVersion}</version>
+ <executions>
+ <execution>
+ <id>attached-p2-metadata</id>
+ <phase>package</phase>
+ <goals>
+ <goal>p2-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
trunk/maven/features/org.jboss.tools.maven.jdt.feature/sourceTemplateFeature/.gitkeep
===================================================================
Modified: trunk/maven/features/pom.xml
===================================================================
--- trunk/maven/features/pom.xml 2012-05-10 11:38:49 UTC (rev 40910)
+++ trunk/maven/features/pom.xml 2012-05-10 13:17:28 UTC (rev 40911)
@@ -27,6 +27,7 @@
<module>org.jboss.tools.maven.profiles.feature</module>
<module>org.jboss.tools.maven.gwt.feature</module>
<module>org.jboss.tools.maven.sourcelookup.feature</module>
+ <module>org.jboss.tools.maven.jdt.feature</module>
</modules>
<repositories>
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/.classpath
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/.classpath (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/.classpath 2012-05-10 13:17:28 UTC (rev
40911)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/.project
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/.project (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/.project 2012-05-10 13:17:28 UTC (rev
40911)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.maven.jdt</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/org.eclipse.jdt.core.prefs 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/org.eclipse.m2e.core.prefs
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/org.eclipse.m2e.core.prefs
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/.settings/org.eclipse.m2e.core.prefs 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/META-INF/MANIFEST.MF 2012-05-10 13:17:28
UTC (rev 40911)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.jboss.tools.maven.jdt;singleton:=true
+Bundle-Version: 1.3.0.qualifier
+Bundle-Activator: org.jboss.tools.maven.jdt.MavenJdtActivator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core,
+ org.eclipse.m2e.core;bundle-version="1.0.0",
+ org.eclipse.m2e.jdt;bundle-version="1.0.0",
+ org.eclipse.m2e.maven.runtime;bundle-version="1.0.0"
+Bundle-Localization: plugin
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6,
+ JavaSE-1.7
+Bundle-Vendor: %Bundle-Vendor
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/about.html
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/about.html (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/about.html 2012-05-10 13:17:28 UTC (rev
40911)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1" />
+<title>JBoss Maven CDI Configurator</title>
+<style type="text/css" media="screen">
+<!--
+ body {
+ font-family: Sans-serif, Arial, Helvetica;
+ }
+
+-->
+</style>
+</head>
+<body>
+<h1>JBoss Maven CDI Configurator</h1>
+
+<p>
+This plugin is part of the JBoss Tools developed by the <a
href="http://www.jboss.com">JBoss Inc.</a>
+</p>
+
+<p>Information about this plugin is available at <a
href="http://www.jboss.org/tools">JBoss Tools project
page</a></p>
+
+<p>
+This software is distributed under the terms of the Eclipse Public License - v 1.0
+(see <a
href="www.eclipse.org/legal/epl-v10.html">Eclipse Public License
- Version 1.0</a>).
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/about.ini
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/about.ini (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/about.ini 2012-05-10 13:17:28 UTC (rev
40911)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog
(translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=jboss_about.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which
the
+# welcome page is to be opened.
+# optional
+
+
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/about.mappings
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/about.mappings
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/about.mappings 2012-05-10 13:17:28 UTC
(rev 40911)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/about.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/about.properties
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/about.properties 2012-05-10 13:17:28 UTC
(rev 40911)
@@ -0,0 +1,2 @@
+blurb=JBoss Maven CDI Configurator\n\nVersion\: {featureVersion}\n\n(c) Copyright (c) Red
Hat, Inc., contributors and others 2004 - 2012. All rights reserved.\nVisit
http\://jboss.org/tools
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/build.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/build.properties
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/build.properties 2012-05-10 13:17:28 UTC
(rev 40911)
@@ -0,0 +1,12 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html,\
+ about.ini,\
+ about.mappings,\
+ about.properties,\
+ jboss_about.png,\
+ lifecycle-mapping-metadata.xml
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/jboss_about.png
===================================================================
(Binary files differ)
Property changes on: trunk/maven/plugins/org.jboss.tools.maven.jdt/jboss_about.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/lifecycle-mapping-metadata.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/lifecycle-mapping-metadata.xml
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/lifecycle-mapping-metadata.xml 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lifecycleMappingMetadata>
+
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <versionRange>[2.0,)</versionRange>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <configurator>
+ <id>org.jboss.tools.maven.jdt.configurator.endorsedlib</id>
+ </configurator>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+
+</lifecycleMappingMetadata>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/plugin.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/plugin.properties
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/plugin.properties 2012-05-10 13:17:28
UTC (rev 40911)
@@ -0,0 +1,3 @@
+Bundle-Vendor = JBoss by Red Hat
+Bundle-Name = JBoss Maven JDT Configurator
+Endorsed_Lib_Configurator_label = Endorsed lib configurator
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/plugin.xml (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/plugin.xml 2012-05-10 13:17:28 UTC (rev
40911)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
+ </extension>
+
+ <extension point="org.eclipse.jdt.core.classpathContainerInitializer"
+ id="endorsedLibrariesClasspathContainer"
+ name="Endorsed Libraries">
+ <classpathContainerInitializer
+ id="org.jboss.tools.maven.jdt.ENDORSED_LIB_CLASSPATH_CONTAINER"
+
class="org.jboss.tools.maven.jdt.configurators.EndorsedLibrariesContainerInitializer"/>
+ </extension>
+
+ <extension point="org.eclipse.m2e.core.projectConfigurators">
+ <configurator
+ id="org.jboss.tools.maven.jdt.configurator.endorsedlib"
+
class="org.jboss.tools.maven.jdt.configurators.EndorsedLibProjectConfigurator"
+ name="%Endorsed_Lib_Configurator_label"
+ secondaryTo="org.eclipse.m2e.jdt.javaConfigurator"/>
+ </extension>
+
+</plugin>
Added: trunk/maven/plugins/org.jboss.tools.maven.jdt/pom.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jdt/pom.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jdt/pom.xml 2012-05-10 13:17:28 UTC (rev
40911)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools.maven</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.maven.plugins</groupId>
+ <artifactId>org.jboss.tools.maven.jdt</artifactId>
+
+ <packaging>eclipse-plugin</packaging>
+</project>
\ No newline at end of file
Added:
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/MavenJdtActivator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/MavenJdtActivator.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/MavenJdtActivator.java 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,87 @@
+/*************************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.jdt;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.maven.jdt.configurators.EndorsedLibrariesManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class MavenJdtActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.maven.jdt";
//$NON-NLS-1$
+
+ // The shared instance
+ private static MavenJdtActivator plugin;
+
+ private EndorsedLibrariesManager endorsedLibrariesManager;
+
+ /**
+ * The constructor
+ */
+ public MavenJdtActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ File stateLocationDir = getStateLocation().toFile();
+ endorsedLibrariesManager = new EndorsedLibrariesManager(stateLocationDir);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static MavenJdtActivator getDefault() {
+ return plugin;
+ }
+
+ public static void log(Throwable e) {
+ log(e.getLocalizedMessage(), e);
+ }
+
+ public static void log(String message) {
+ IStatus status = new Status(IStatus.WARNING, PLUGIN_ID, message, null);
+ getDefault().getLog().log(status);
+ }
+
+
+ public static void log(String message, Throwable e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
+ getDefault().getLog().log(status);
+ }
+
+ public EndorsedLibrariesManager getEndorsedLibrariesManager() {
+ return endorsedLibrariesManager;
+ }
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/ClasspathHelpers.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/ClasspathHelpers.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/ClasspathHelpers.java 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,92 @@
+package org.jboss.tools.maven.jdt.configurators;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.m2e.jdt.IClasspathDescriptor;
+import org.eclipse.m2e.jdt.IClasspathEntryDescriptor;
+import org.eclipse.m2e.jdt.internal.ClasspathDescriptor;
+import org.eclipse.m2e.jdt.internal.ClasspathEntryDescriptor;
+import org.eclipse.m2e.jdt.internal.MavenClasspathHelpers;
+import org.jboss.tools.maven.jdt.MavenJdtActivator;
+
+public class ClasspathHelpers {
+
+ public static final String CONTAINER_ID = MavenJdtActivator.PLUGIN_ID
+ + ".ENDORSED_LIB_CLASSPATH_CONTAINER";
+
+ public static boolean isEndorsedDirsClasspathContainer(IPath containerPath) {
+ return containerPath != null && containerPath.segmentCount() > 0
+ && CONTAINER_ID.equals(containerPath.segment(0));
+ }
+
+ public static IClasspathEntry getDefaultContainerEntry() {
+ return JavaCore.newContainerEntry(new Path(CONTAINER_ID));
+ }
+
+ public static IClasspathContainer getEndorsedDirsClasspathContainer(
+ IJavaProject project) throws JavaModelException {
+ IClasspathEntry[] entries = project.getRawClasspath();
+ for (int i = 0; i < entries.length; i++) {
+ IClasspathEntry entry = entries[i];
+ if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER
+ && isEndorsedDirsClasspathContainer(entry.getPath())) {
+ return JavaCore.getClasspathContainer(entry.getPath(), project);
+ }
+ }
+ return null;
+ }
+
+ public static IClasspathEntry addEndorsedLibClasspathContainer(IClasspathDescriptor
classpath) {
+ IClasspathEntry cpe = getDefaultContainerEntry();
+ ClasspathEntryDescriptor entry = new ClasspathEntryDescriptor(cpe);
+ entry.setClasspathAttribute("org.eclipse.jst.component.nondependency",
"");
+ classpath.getEntryDescriptors().add(0,entry);
+ return cpe;
+ }
+
+ public static void removeEndorsedLibClasspathContainer( IClasspathDescriptor classpath )
{
+ // remove any old endorsed dirs container entries
+ classpath.removeEntry(new ClasspathDescriptor.EntryFilter() {
+ public boolean accept(IClasspathEntryDescriptor entry) {
+ return isEndorsedDirsClasspathContainer(entry.getPath());
+ }
+ });
+ }
+
+ public static IClasspathEntry getEndorsedDirsContainerEntry( IJavaProject javaProject )
{
+ if (javaProject != null) {
+ try {
+ for (IClasspathEntry entry : javaProject.getRawClasspath()) {
+ if (isEndorsedDirsClasspathContainer(entry.getPath())) {
+ return entry;
+ }
+ }
+ } catch (JavaModelException ex) {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static void removeEndorsedLibClasspathContainer(IProject project) throws
JavaModelException {
+ IJavaProject javaProject = JavaCore.create(project);
+ if(javaProject != null) {
+ // remove classpatch container from JavaProject
+ ArrayList<IClasspathEntry> newEntries = new
ArrayList<IClasspathEntry>();
+ for(IClasspathEntry entry : javaProject.getRawClasspath()) {
+ if(!isEndorsedDirsClasspathContainer(entry.getPath())) {
+ newEntries.add(entry);
+ }
+ }
+ javaProject.setRawClasspath(newEntries.toArray(new
IClasspathEntry[newEntries.size()]), null);
+ }
+ }
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibProjectConfigurator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibProjectConfigurator.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibProjectConfigurator.java 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,223 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.jdt.configurators;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.lifecycle.MavenExecutionPlan;
+import org.apache.maven.plugin.MojoExecution;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
+import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
+import org.eclipse.m2e.jdt.IClasspathDescriptor;
+import org.eclipse.m2e.jdt.IJavaProjectConfigurator;
+import org.jboss.tools.maven.jdt.MavenJdtActivator;
+
+
+/**
+ * Endorsed Libraries project configurator
+ *
+ * @author Fred Bricon
+ *
+ */
+public class EndorsedLibProjectConfigurator extends AbstractProjectConfigurator
implements IJavaProjectConfigurator {
+
+ private static final Pattern jAVA_ENDORSED_DIRS_PATTERN =
Pattern.compile("-Djava.endorsed.dirs=([^ \\t]+)");
+
+ @Override
+ public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor)
throws CoreException {
+
+ File[] endorsedDirs = getEndorsedDirs(request.getMavenProjectFacade(), monitor);
+ if (endorsedDirs == null || endorsedDirs.length == 0) {
+ return;
+ }
+
+ boolean missingEndorsedDir = checkMissingDirs(endorsedDirs);
+ if (missingEndorsedDir && canExecuteDependencyCopy()) {
+ //TODO trigger dependency:copy
+ missingEndorsedDir = checkMissingDirs(endorsedDirs);
+ }
+ if (missingEndorsedDir) {
+ //TODO add marker
+ System.err.println("Some Endorsed directories are missing for
"+request.getProject().getName());
+ }
+ }
+
+ private boolean canExecuteDependencyCopy() {
+ //TODO check preferences?
+ return true;
+ }
+
+ private boolean checkMissingDirs(File[] endorsedDirs) {
+ for (File dir : endorsedDirs) {
+ if (!dir.exists()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void configureClasspath(IMavenProjectFacade facade,
+ IClasspathDescriptor classpath, IProgressMonitor monitor)
+ throws CoreException {
+ // Nothing to configure here
+ }
+
+ public void configureRawClasspath(ProjectConfigurationRequest request,
+ IClasspathDescriptor classpath, IProgressMonitor monitor)
+ throws CoreException {
+
+ IJavaProject javaProject = JavaCore.create(request.getProject());
+ if (javaProject == null) {
+ return;
+ }
+
+ File[] endorsedDirs = getEndorsedDirs(request.getMavenProjectFacade(), monitor);
+
+ if (endorsedDirs == null || endorsedDirs.length == 0){
+ ClasspathHelpers.removeEndorsedLibClasspathContainer(classpath);
+ return;
+ }
+
+ getEndorsedLibrariesManager().configureEndorsedLibs(javaProject, classpath,
endorsedDirs, monitor);
+ }
+
+ private File[] getEndorsedDirs(IMavenProjectFacade mavenProjectFacade, IProgressMonitor
monitor) throws CoreException {
+ MavenSession session = createSession(mavenProjectFacade, monitor);
+ MojoExecution mojoExecution = getCompilerMojoExecution(mavenProjectFacade, session,
monitor);
+
+ //Parse <compilerArgument> for -Djava.endorsed.dirs
+ String compilerArgument = maven.getMojoParameterValue(session, mojoExecution,
"compilerArgument", String.class);
+ File[] javaEndorsedDirs = parseJavaEndorsedDirs(mavenProjectFacade.getProject(),
compilerArgument);
+
+ //Check <compilerArguments> for <endorseddirs>
+ @SuppressWarnings("unchecked")
+ Map<String, String> compilerArguments = maven.getMojoParameterValue(session,
mojoExecution, "compilerArguments", Map.class);
+ String endorsedDirsArg = (compilerArguments ==
null)?null:compilerArguments.get("endorseddirs");
+ File[] endorsedDirs = parseEndorsedDirs(mavenProjectFacade.getProject(),
endorsedDirsArg);
+
+ return concat(javaEndorsedDirs, endorsedDirs);
+ }
+
+ private File[] parseJavaEndorsedDirs(IProject project, String compilerArgument) {
+ if (compilerArgument == null) {
+ return null;
+ }
+ Matcher matcher = jAVA_ENDORSED_DIRS_PATTERN.matcher(compilerArgument);
+ if (matcher.matches()) {
+ String endorsedDirs = matcher.group(1);
+ return parseEndorsedDirs(project, endorsedDirs);
+ }
+ return null;
+ }
+
+ private File[] parseEndorsedDirs(IProject project, String endorsedDirs) {
+ if (endorsedDirs == null){
+ return null;
+ }
+ //Remove quotes, use system separators
+ endorsedDirs = endorsedDirs.replaceAll("\"", "");
+
+ //Quote from
http://docs.oracle.com/javase/6/docs/technotes/guides/standards/
+ //"If more than one directory path is specified by java.endorsed.dirs,
+ //they must be separated by File.pathSeparatorChar."
+ String[] paths = endorsedDirs.split(""+File.pathSeparatorChar);
+
+ //Convert dir paths to Files
+ List<File> dirs = new ArrayList<File>(paths.length);
+ for (String path : paths) {
+ IPath p = new Path(useSystemSeparator(path));
+ if (!p.isAbsolute()) {
+ p = project.getLocation().append(p);
+ }
+ File lib = new File(p.toOSString());
+ dirs.add(lib);
+ }
+
+ return dirs.toArray(new File[0]);
+ }
+
+
+ private static String useSystemSeparator(String name) {
+ if (name == null) return null;
+ return name.replace('/', File.separatorChar)
+ .replace('\\', File.separatorChar);
+ }
+
+ private MojoExecution getCompilerMojoExecution(IMavenProjectFacade mavenProjectFacade,
+ MavenSession session,
+ IProgressMonitor monitor) throws CoreException {
+ MavenExecutionPlan executionPlan = maven.calculateExecutionPlan(session,
+ mavenProjectFacade.getMavenProject(),
+ Collections.singletonList("compile"),
+ true,
+ monitor);
+ MojoExecution mojoExecution = getExecution(executionPlan,
"maven-compiler-plugin", "compile");
+ return mojoExecution;
+ }
+
+ private MavenSession createSession(IMavenProjectFacade mavenProjectFacade,
IProgressMonitor monitor) throws CoreException {
+ IFile pomResource = mavenProjectFacade.getPom();
+ MavenExecutionRequest request = projectManager.createExecutionRequest(pomResource,
+ mavenProjectFacade.getResolverConfiguration(),
+ monitor);
+ MavenSession session = maven.createSession(request,
mavenProjectFacade.getMavenProject());
+ return session;
+ }
+
+ private MojoExecution getExecution(MavenExecutionPlan executionPlan, String
artifactId, String goal) throws CoreException {
+ for(MojoExecution execution : executionPlan.getMojoExecutions()) {
+ if(artifactId.equals(execution.getArtifactId()) &&
goal.equals(execution.getGoal())) {
+ return execution;
+ }
+ }
+ return null;
+ }
+
+ private static <T> T[] concat(T[] first, T[] second) {
+ if (second == null) {
+ return first;
+ }
+ if (first == null) {
+ return second;
+ }
+ T[] result = Arrays.copyOf(first, first.length + second.length);
+ System.arraycopy(second, 0, result, first.length, second.length);
+ return result;
+ }
+
+ private EndorsedLibrariesManager getEndorsedLibrariesManager() {
+ return MavenJdtActivator.getDefault().getEndorsedLibrariesManager();
+ }
+
+ public void unconfigure(ProjectConfigurationRequest request, IProgressMonitor monitor)
throws CoreException {
+ super.unconfigure(request, monitor);
+ ClasspathHelpers.removeEndorsedLibClasspathContainer(request.getProject());
+ }
+
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesContainer.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesContainer.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesContainer.java 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,55 @@
+package org.jboss.tools.maven.jdt.configurators;
+
+import java.io.Serializable;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+
+/**
+ * Endorsed libraries classpath container
+ */
+public class EndorsedLibrariesContainer implements IClasspathContainer, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final IClasspathEntry[] entries;
+ private final IPath path;
+
+ public EndorsedLibrariesContainer(IPath path, IClasspathEntry[] entries) {
+ this.path = path;
+ this.entries = entries;
+ }
+
+ public String getDescription() {
+ return "Endorsed Libraries";
+ }
+
+ public int getKind() {
+ return IClasspathContainer.K_APPLICATION;
+ }
+
+ public synchronized IClasspathEntry[] getClasspathEntries() {
+ return entries;
+ }
+
+ public IPath getPath() {
+ return path;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ if (path != null){
+ sb.append(path.toPortableString());
+ }
+ if (entries != null) {
+ sb.append(" [");
+ for (IClasspathEntry cpe : entries) {
+ sb.append(cpe.getPath()).append(", ");
+ }
+ sb.append("]");
+ }
+ return sb.toString();
+ }
+
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesContainerInitializer.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesContainerInitializer.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesContainerInitializer.java 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2010 Sonatype, Inc. and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ * Red Hat, Inc. - Changed behaviour to support Endorsed Libraries
+ *******************************************************************************/
+
+package org.jboss.tools.maven.jdt.configurators;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.IMavenConfiguration;
+import org.eclipse.m2e.core.project.IMavenProjectRegistry;
+import org.eclipse.m2e.core.project.MavenUpdateRequest;
+import org.jboss.tools.maven.jdt.MavenJdtActivator;
+
+
+/**
+ * Endorsed Libraries Container Initializer
+ *
+ * @author Eugene Kuleshov
+ * @author Fred Bricon
+ */
+public class EndorsedLibrariesContainerInitializer extends ClasspathContainerInitializer
{
+
+ public void initialize(IPath containerPath, IJavaProject project) {
+ if(ClasspathHelpers.isEndorsedDirsClasspathContainer(containerPath)) {
+ try {
+ IClasspathContainer mavenContainer =
getBuildPathManager().getSavedContainer(project.getProject());
+ if(mavenContainer != null) {
+ JavaCore.setClasspathContainer(containerPath, new IJavaProject[] {project},
+ new IClasspathContainer[] {mavenContainer}, new NullProgressMonitor());
+ return;
+ }
+ } catch(CoreException ex) {
+ MavenJdtActivator.log("Exception initializing classpath container " +
containerPath.toString(), ex);
+ }
+
+ // force refresh if can't read persisted state
+ IMavenConfiguration configuration = MavenPlugin.getMavenConfiguration();
+ MavenUpdateRequest request = new MavenUpdateRequest(project.getProject(),
configuration.isOffline(), false);
+ getMavenProjectManager().refresh(request);
+ }
+ }
+
+
+ private EndorsedLibrariesManager getBuildPathManager() {
+ return MavenJdtActivator.getDefault().getEndorsedLibrariesManager();
+ }
+
+ private IMavenProjectRegistry getMavenProjectManager() {
+ return MavenPlugin.getMavenProjectRegistry();
+ }
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesManager.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesManager.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/EndorsedLibrariesManager.java 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2012 Sonatype, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ * Red Hat, Inc. - Changed behaviour to support Endorsed Libraries
+ *******************************************************************************/
+
+package org.jboss.tools.maven.jdt.configurators;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.m2e.jdt.IClasspathDescriptor;
+import org.jboss.tools.maven.jdt.MavenJdtActivator;
+import org.jboss.tools.maven.jdt.configurators.xpl.MavenClasspathContainerSaveHelper;
+
+public class EndorsedLibrariesManager {
+
+ private File stateLocationDir;
+
+ public EndorsedLibrariesManager(File containerLocationDir) {
+ stateLocationDir = containerLocationDir;
+ }
+
+ /**
+ * Adds the Endorsed Libraries classpath library to a project's classpath. It's
added beore any other classpath build path.
+ * @param javaProject
+ * @param classpath
+ * @param endorsedDirs
+ * @param monitor
+ * @throws CoreException
+ */
+ public void configureEndorsedLibs(IJavaProject javaProject, IClasspathDescriptor
classpath, File[] endorsedDirs,
+ IProgressMonitor monitor) throws CoreException {
+
+ if(javaProject != null && classpath != null) {
+
+ IClasspathEntry[] classpathEntries = getClasspathEntries(javaProject, endorsedDirs,
monitor);
+
+ ClasspathHelpers.removeEndorsedLibClasspathContainer(classpath);
+
+ if (classpathEntries.length > 0) {
+ IClasspathEntry containerEntry =
ClasspathHelpers.addEndorsedLibClasspathContainer(classpath);
+ IPath path = containerEntry != null ? containerEntry.getPath() : new
Path(ClasspathHelpers.CONTAINER_ID);
+ IClasspathContainer container = new EndorsedLibrariesContainer(path,
classpathEntries);
+ JavaCore.setClasspathContainer(container.getPath(), new IJavaProject[]
{javaProject},
+ new IClasspathContainer[] {container}, monitor);
+ saveContainerState(javaProject.getProject(), container);
+ }
+ }
+ }
+
+ /**
+ * Returns the classpath entries found under the endorsed directories
+ */
+ private IClasspathEntry[] getClasspathEntries(IJavaProject javaProject, File[]
endorsedDirs, IProgressMonitor monitor) {
+ List<IClasspathEntry> cpes = new ArrayList<IClasspathEntry>();
+ for (File dir : endorsedDirs) {
+ if (dir.isDirectory() && dir.canRead()) {
+ setEntries(dir, cpes);
+ }
+ }
+ return (IClasspathEntry[]) cpes.toArray(new IClasspathEntry[0]);
+ }
+
+ /**
+ * Adds all the jar and zip files found under the lib directory to the list of {@link
IClasspathEntry}
+ */
+ private void setEntries(File lib, List<IClasspathEntry> cpes) {
+ if (!lib.canRead()) {
+ return;
+ }
+ for (File f : lib.listFiles(new JarFilter())) {
+ if (f.isFile()) {
+ IPath fullPath = new Path(f.getAbsolutePath());
+ IClasspathEntry entry = JavaCore.newLibraryEntry(fullPath, null, null);
+ if (!cpes.contains(entry)) {
+ cpes.add(entry);
+ }
+ }
+ }
+ }
+
+
+ private void saveContainerState(IProject project, IClasspathContainer container) {
+ File containerStateFile = getContainerStateFile(project);
+ FileOutputStream is = null;
+ try {
+ is = new FileOutputStream(containerStateFile);
+ new MavenClasspathContainerSaveHelper().writeContainer(container, is);
+ } catch (IOException ex) {
+ MavenJdtActivator.log(
+ "Can't save classpath container state for " + project.getName(), ex);
//$NON-NLS-1$
+ } finally {
+ closeQuietly(is, "Can't close output stream for " +
containerStateFile.getAbsolutePath());
+ }
+ }
+
+ public IClasspathContainer getSavedContainer(IProject project)
+ throws CoreException {
+ File containerStateFile = getContainerStateFile(project);
+ if (!containerStateFile.exists()) {
+ return null;
+ }
+
+ FileInputStream is = null;
+ try {
+ is = new FileInputStream(containerStateFile);
+ return new MavenClasspathContainerSaveHelper().readContainer(is);
+ } catch (IOException ex) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ MavenJdtActivator.PLUGIN_ID, -1, //
+ "Can't read classpath container state for "
+ + project.getName(), ex));
+ } catch (ClassNotFoundException ex) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ MavenJdtActivator.PLUGIN_ID, -1, //
+ "Can't read classpath container state for "
+ + project.getName(), ex));
+ } finally {
+ closeQuietly(is, "Can't close output stream for " +
containerStateFile.getAbsolutePath());
+ }
+ }
+
+ private void closeQuietly(Closeable c, String message) {
+ if (c != null) {
+ try {
+ c.close();
+ } catch (IOException e) {
+ MavenJdtActivator.log(message, e);
+ }
+ }
+ }
+
+ private File getContainerStateFile(IProject project) {
+ return new File(stateLocationDir, project.getName() + ".container");
//$NON-NLS-1$
+ }
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/JarFilter.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/JarFilter.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/JarFilter.java 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,12 @@
+package org.jboss.tools.maven.jdt.configurators;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+public class JarFilter implements FilenameFilter {
+
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar") || name.endsWith(".zip");
+ }
+
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/xpl/MavenClasspathContainerSaveHelper.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/xpl/MavenClasspathContainerSaveHelper.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jdt/src/org/jboss/tools/maven/jdt/configurators/xpl/MavenClasspathContainerSaveHelper.java 2012-05-10
13:17:28 UTC (rev 40911)
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2010 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.maven.jdt.configurators.xpl;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+
+
+/**
+ * BuildPath save helper copied as-is from {@link
org.eclipse.m2e.jdt.internal.MavenClasspathContainerSaveHelper}
+ *
+ * @author Eugene Kuleshov
+ */
+public class MavenClasspathContainerSaveHelper {
+
+ public IClasspathContainer readContainer(InputStream input) throws IOException,
ClassNotFoundException {
+ ObjectInputStream is = new ObjectInputStream(new BufferedInputStream(input)) {
+ {
+ enableResolveObject(true);
+ }
+ protected Object resolveObject(Object o) throws IOException {
+ if(o instanceof ProjectEntryReplace) {
+ return ((ProjectEntryReplace) o).getEntry();
+ } else if(o instanceof LibraryEntryReplace) {
+ return ((LibraryEntryReplace) o).getEntry();
+ } else if(o instanceof ClasspathAttributeReplace) {
+ return ((ClasspathAttributeReplace) o).getAttribute();
+ } else if(o instanceof AccessRuleReplace) {
+ return ((AccessRuleReplace) o).getAccessRule();
+ } else if(o instanceof PathReplace) {
+ return ((PathReplace) o).getPath();
+ }
+ return super.resolveObject(o);
+ }
+ };
+ return (IClasspathContainer) is.readObject();
+ }
+
+ public void writeContainer(IClasspathContainer container, OutputStream output) throws
IOException {
+ ObjectOutputStream os = new ObjectOutputStream(new BufferedOutputStream(output)) {
+ {
+ enableReplaceObject(true);
+ }
+
+ protected Object replaceObject(Object o) throws IOException {
+ if(o instanceof IClasspathEntry) {
+ IClasspathEntry e = (IClasspathEntry) o;
+ if(e.getEntryKind()==IClasspathEntry.CPE_PROJECT) {
+ return new ProjectEntryReplace(e);
+ } else if(e.getEntryKind()==IClasspathEntry.CPE_LIBRARY) {
+ return new LibraryEntryReplace(e);
+ }
+ } else if(o instanceof IClasspathAttribute) {
+ return new ClasspathAttributeReplace((IClasspathAttribute) o);
+ } else if(o instanceof IAccessRule) {
+ return new AccessRuleReplace((IAccessRule) o);
+ } else if(o instanceof IPath) {
+ return new PathReplace((IPath) o);
+ }
+ return super.replaceObject(o);
+ }
+ };
+ os.writeObject(container);
+ os.flush();
+ }
+
+ /**
+ * A library IClasspathEntry replacement used for object serialization
+ */
+ static final class LibraryEntryReplace implements Serializable {
+ private static final long serialVersionUID = 3901667379326978799L;
+
+ private final IPath path;
+ private final IPath sourceAttachmentPath;
+ private final IPath sourceAttachmentRootPath;
+ private final IClasspathAttribute[] extraAttributes;
+ private final boolean exported;
+ private final IAccessRule[] accessRules;
+
+ LibraryEntryReplace(IClasspathEntry entry) {
+ this.path = entry.getPath();
+ this.sourceAttachmentPath = entry.getSourceAttachmentPath();
+ this.sourceAttachmentRootPath = entry.getSourceAttachmentRootPath();
+ this.accessRules = entry.getAccessRules();
+ this.extraAttributes = entry.getExtraAttributes();
+ this.exported = entry.isExported();
+ }
+
+ IClasspathEntry getEntry() {
+ return JavaCore.newLibraryEntry(path, sourceAttachmentPath,
sourceAttachmentRootPath, //
+ accessRules, extraAttributes, exported);
+ }
+ }
+
+ /**
+ * A project IClasspathEntry replacement used for object serialization
+ */
+ static final class ProjectEntryReplace implements Serializable {
+ private static final long serialVersionUID = -2397483865904288762L;
+
+ private final IPath path;
+ private final IClasspathAttribute[] extraAttributes;
+ private final IAccessRule[] accessRules;
+ private final boolean exported;
+ private final boolean combineAccessRules;
+
+ ProjectEntryReplace(IClasspathEntry entry) {
+ this.path = entry.getPath();
+ this.accessRules = entry.getAccessRules();
+ this.extraAttributes = entry.getExtraAttributes();
+ this.exported = entry.isExported();
+ this.combineAccessRules = entry.combineAccessRules();
+ }
+
+ IClasspathEntry getEntry() {
+ return JavaCore.newProjectEntry(path, accessRules, //
+ combineAccessRules, extraAttributes, exported);
+ }
+ }
+
+ /**
+ * An IClasspathAttribute replacement used for object serialization
+ */
+ static final class ClasspathAttributeReplace implements Serializable {
+ private static final long serialVersionUID = 6370039352012628029L;
+
+ private final String name;
+ private final String value;
+
+ ClasspathAttributeReplace(IClasspathAttribute attribute) {
+ this.name = attribute.getName();
+ this.value = attribute.getValue();
+ }
+
+ IClasspathAttribute getAttribute() {
+ return JavaCore.newClasspathAttribute(name, value);
+ }
+ }
+
+ /**
+ * An IAccessRule replacement used for object serialization
+ */
+ static final class AccessRuleReplace implements Serializable {
+ private static final long serialVersionUID = 7315582893941374715L;
+
+ private final IPath pattern;
+ private final int kind;
+
+ AccessRuleReplace(IAccessRule accessRule) {
+ pattern = accessRule.getPattern();
+ kind = accessRule.getKind();
+ }
+
+ IAccessRule getAccessRule() {
+ return JavaCore.newAccessRule(pattern, kind);
+ }
+ }
+
+ /**
+ * An IPath replacement used for object serialization
+ */
+ static final class PathReplace implements Serializable {
+ private static final long serialVersionUID = -2361259525684491181L;
+
+ private final String path;
+
+ PathReplace(IPath path) {
+ this.path = path.toPortableString();
+ }
+
+ IPath getPath() {
+ return Path.fromPortableString(path);
+ }
+ }
+
+}
Modified: trunk/maven/plugins/pom.xml
===================================================================
--- trunk/maven/plugins/pom.xml 2012-05-10 11:38:49 UTC (rev 40910)
+++ trunk/maven/plugins/pom.xml 2012-05-10 13:17:28 UTC (rev 40911)
@@ -6,6 +6,7 @@
<groupId>org.jboss.tools</groupId>
<artifactId>maven</artifactId>
<version>1.3.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
</parent>
<groupId>org.jboss.tools.maven</groupId>
<artifactId>plugins</artifactId>
@@ -29,6 +30,7 @@
<module>org.jboss.tools.maven.gwt</module>
<module>org.jboss.tools.maven.sourcelookup.core</module>
<module>org.jboss.tools.maven.sourcelookup.ui</module>
- </modules>
+ <module>org.jboss.tools.maven.jdt</module>
+ </modules>
</project>
Modified: trunk/maven/site/category.xml
===================================================================
--- trunk/maven/site/category.xml 2012-05-10 11:38:49 UTC (rev 40910)
+++ trunk/maven/site/category.xml 2012-05-10 13:17:28 UTC (rev 40911)
@@ -47,6 +47,9 @@
<feature
url="features/org.jboss.tools.maven.sourcelookup.feature_0.0.0.jar"
id="org.jboss.tools.maven.sourcelookup.feature" version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
</feature>
+ <feature url="features/org.jboss.tools.maven.jdt.feature_0.0.0.jar"
id="org.jboss.tools.maven.jdt.feature" version="0.0.0">
+ <category name="JBoss Tools maven Nightly Build Update Site"/>
+ </feature>
<!-- Sources -->
<feature url="features/org.jboss.tools.maven.feature.source_0.0.0.jar"
id="org.jboss.tools.maven.feature.source" version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
@@ -90,4 +93,8 @@
<feature
url="features/org.jboss.tools.maven.sourcelookup.feature.source_0.0.0.jar"
id="org.jboss.tools.maven.sourcelookup.feature.source"
version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
</feature>
+ <feature url="features/org.jboss.tools.maven.jdt.feature.source_0.0.0.jar"
id="org.jboss.tools.maven.jdt.feature.source" version="0.0.0">
+ <category name="JBoss Tools maven Nightly Build Update Site"/>
+ </feature>
+
</site>