notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1468 - in development/main/magic/spells/eclipse: etc/deliverables/eclipses etc/deliverables/templates src/main/net/dpml/magic/eclipse
- From: andreas.ronge AT jayway.se
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1468 - in development/main/magic/spells/eclipse: etc/deliverables/eclipses etc/deliverables/templates src/main/net/dpml/magic/eclipse
- Date: Thu, 13 Jan 2005 10:14:00 +0100
Author: andreas.ronge AT jayway.se
Date: Thu Jan 13 10:14:00 2005
New Revision: 1468
Modified:
development/main/magic/spells/eclipse/etc/deliverables/eclipses/module-classpath.eclipse
development/main/magic/spells/eclipse/etc/deliverables/templates/eclipse.template
development/main/magic/spells/eclipse/src/main/net/dpml/magic/eclipse/EclipseTask.java
Log:
fixed bug: duplicated resources in .classpath
made it possible to load classpath fragment from URL (and not only artifacts)
Added configuration via template
Modified:
development/main/magic/spells/eclipse/etc/deliverables/eclipses/module-classpath.eclipse
==============================================================================
---
development/main/magic/spells/eclipse/etc/deliverables/eclipses/module-classpath.eclipse
(original)
+++
development/main/magic/spells/eclipse/etc/deliverables/eclipses/module-classpath.eclipse
Thu Jan 13 10:14:00 2005
@@ -3,4 +3,6 @@
<classpathentry kind="src" path="impl/src/main"/>
<classpathentry kind="src" path="test/src/test"/>
- <classpathentry kind="output" path="target/eclipse-classes"/>
\ No newline at end of file
+ <classpathentry kind="output" path="target/eclipse-classes"/>
+
+
\ No newline at end of file
Modified:
development/main/magic/spells/eclipse/etc/deliverables/templates/eclipse.template
==============================================================================
---
development/main/magic/spells/eclipse/etc/deliverables/templates/eclipse.template
(original)
+++
development/main/magic/spells/eclipse/etc/deliverables/templates/eclipse.template
Thu Jan 13 10:14:00 2005
@@ -21,16 +21,23 @@
<project name="eclipse"
xmlns:magic="antlib:net.dpml.magic" >
- <target name="eclipse" depends="prepare" unless="project.eclipse.disable" >
+ <target name="eclipse" unless="project.eclipse.disable" >
+
<property name="project.eclipse.project.uri"
value="artifact:eclipse:dpml/magic/project"/>
<property name="project.eclipse.classpath.uri"
value="artifact:eclipse:dpml/magic/classpath"/>
+
+ <!-- is empty strings then the default values will be used -->
+ <property name="project.eclipse.project.keys" value=""/>
+ <property name="project.eclipse.project.name" value=""/>
<magic:plugin uri="@PLUGIN-URI@"/>
<mkdir dir="target/eclipse"/>
<eclipse xmlns="plugin:dpml/magic/dpml-magic-eclipse"
projectUri="${project.eclipse.project.uri}"
- classpathUri="${project.eclipse.classpath.uri}"/>
+ classpathUri="${project.eclipse.classpath.uri}"
+ projectKeys="${project.eclipse.project.keys}"
+ projectName="${project.eclipse.project.name}" />
</target>
</project>
Modified:
development/main/magic/spells/eclipse/src/main/net/dpml/magic/eclipse/EclipseTask.java
==============================================================================
---
development/main/magic/spells/eclipse/src/main/net/dpml/magic/eclipse/EclipseTask.java
(original)
+++
development/main/magic/spells/eclipse/src/main/net/dpml/magic/eclipse/EclipseTask.java
Thu Jan 13 10:14:00 2005
@@ -86,7 +86,7 @@
private File m_projectFile;
- private File m_classpathFile;
+ private InputStream m_classpathStream;
private String m_projectKeys;
@@ -196,20 +196,10 @@
*/
public void setClasspathUri( String classpathUri )
{
- try
- {
- URL url = new URL( null, classpathUri, new Handler() );
- m_classpathFile = ( File ) url
- .getContent( new Class[] { File.class } );
- }
- catch ( Throwable e )
- {
- final String error = "Could not resolve the classpath uri ["
- + classpathUri + "]";
- throw new BuildException( error, e );
- }
+ m_classpathStream = getInputStreamFromUrl(classpathUri);
}
+
//
-------------------------------------------------------------------------
// protected methods
//
-------------------------------------------------------------------------
@@ -257,11 +247,12 @@
String keys = getProjectKeys();
+ Set excludeKeys = getExcludeKeysSet();
StringTokenizer tokenizer = new StringTokenizer( keys, ", ", false );
while ( tokenizer.hasMoreTokens() )
{
String key = tokenizer.nextToken();
- createProjectClasspath( writer, key );
+ createProjectClasspath( writer, key, excludeKeys );
}
writer.write( "</classpath>\n" );
@@ -286,10 +277,9 @@
return excludeKeys;
}
- private void createProjectClasspath( Writer writer, String key )
+ private void createProjectClasspath( Writer writer, String key, Set
excludeKeys)
throws IOException
{
- Set excludeKeys = getExcludeKeysSet();
Definition projectDef = getProjectDefinition( key );
ResourceRef[] resourceRefs = projectDef.getResourceRefs();
Collection resources = getResources( resourceRefs );
@@ -298,7 +288,8 @@
{
Resource resource = ( Resource ) iter.next();
- if ( excludeKeys.contains( resource.getKey() ) )
+ String resourceKey = resource.getKey();
+ if ( excludeKeys.contains( resourceKey ) )
{
continue;
}
@@ -308,7 +299,11 @@
if ( !"jar".equalsIgnoreCase( type ) )
continue;
writer.write( " " + getEclipseClasspath( resource ) + "\n" );
+
+ // add key to exclude keys so that we don't add it again
+ excludeKeys.add(resourceKey);
}
+
}
private Definition getProjectDefinition( String key )
@@ -320,14 +315,7 @@
private void appendClasspathHeader( Writer writer )
throws FileNotFoundException, IOException
{
- if ( m_classpathFile == null )
- throw new BuildException( "Missing classpathUri property for
task" );
- if ( !m_classpathFile.canRead() )
- throw new BuildException( "Can't read from resource '"
- + m_classpathFile.getAbsolutePath() );
-
- InputStream in = new FileInputStream( m_classpathFile );
- String inString = readInputStream( in );
+ String inString = readInputStream( m_classpathStream );
writer.write( inString );
}
@@ -417,6 +405,42 @@
return out;
}
+
+ private InputStream getInputStreamFromUrl (String urlString)
+ {
+ InputStream in;
+
+ // try first without transit
+ try
+ {
+ URL url = new URL( urlString );
+ in = (InputStream) url.getContent( );
+ }
+ catch ( Throwable e )
+ {
+ // now try with transit
+ try
+ {
+ URL url = new URL( null, urlString, new Handler() );
+ File file = ( File ) url
+ .getContent( new Class[] { File.class } );
+ in = new FileInputStream(file);
+ }
+ catch ( Throwable e2 )
+ {
+ final String error = "Could not resolve uri ["
+ + urlString + "]";
+ throw new BuildException( error, e2 );
+ }
+ }
+
+ // check inputstream
+ if ( in == null )
+ throw new BuildException( "Can't open resource at '" + urlString
+ "'" );
+
+ return in;
+ }
+
private void closeStream( OutputStream output )
{
if ( null != output )
- svn commit: r1468 - in development/main/magic/spells/eclipse: etc/deliverables/eclipses etc/deliverables/templates src/main/net/dpml/magic/eclipse, andreas . ronge, 01/13/2005
Archive powered by MHonArc 2.6.24.