Subversion Repository Public Repository

litesoft

Diff Revisions 288 vs 289 for /trunk/Java/ScarPlus/src/com/esotericsoftware/scar/Scar.java

Diff revisions: vs.
  @@ -1,6 +1,7 @@
1 1 package com.esotericsoftware.scar;
2 2
3 3 import java.io.*;
4 + import java.lang.reflect.*;
4 5 import java.net.*;
5 6 import java.util.*;
6 7 import java.util.Map.*;
  @@ -183,19 +184,28 @@
183 184
184 185 protected Project instantiate( Class<? extends Project> pClass, File pProjectDir, String pProjectName, Map<Object, Object> pData )
185 186 {
186 - Project zProject = instantiate( pClass, pProjectDir, pProjectName );
187 - zProject.setDirectory( pProjectDir );
188 - zProject.setName( pProjectName );
189 - zProject.setData( pData );
190 - return zProject;
187 + return instantiate( pClass, new Project.Parameters( pProjectName, pProjectDir, pData ) );
191 188 }
192 189
193 - protected Project instantiate( Class<? extends Project> pClass, File pProjectDir, String pProjectName )
190 + protected Project instantiate( Class<? extends Project> pClass, Project.Parameters pParameters )
194 191 {
195 192 Throwable zCause;
196 193 try
197 194 {
198 - return pClass.newInstance();
195 + Constructor zConstructor = pClass.getConstructor( Project.Parameters.class );
196 + return (Project) zConstructor.newInstance( pParameters );
197 + }
198 + catch ( NoSuchMethodException e )
199 + {
200 + zCause = e;
201 + }
202 + catch ( InvocationTargetException e )
203 + {
204 + zCause = e;
205 + }
206 + catch ( ClassCastException e )
207 + {
208 + zCause = e;
199 209 }
200 210 catch ( InstantiationException e )
201 211 {
  @@ -209,7 +219,7 @@
209 219 {
210 220 zCause = e;
211 221 }
212 - throw new RuntimeException( "Unable to Instantiate Project Class for Project: " + pProjectName + " in dir " + pProjectDir, zCause );
222 + throw new RuntimeException( "Unable to Instantiate Project Class for Project: " + pParameters.getName() + " in dir " + pParameters.getDirectory(), zCause );
213 223 }
214 224
215 225 protected Class<? extends Project> createYamlProjectClass()
  @@ -1702,23 +1712,6 @@
1702 1712 }
1703 1713
1704 1714 /**
1705 - * Executes the buildDependencies, clean, compile, jar, and dist utility metshods.
1706 - */
1707 - public void build( Project project )
1708 - throws IOException
1709 - {
1710 - Util.assertNotNull( "Project", project );
1711 -
1712 - buildDependencies( project );
1713 - clean( project );
1714 - compile( project );
1715 - jar( project );
1716 - dist( project );
1717 -
1718 - builtProjects.add( project.get( "name" ) );
1719 - }
1720 -
1721 - /**
1722 1715 * Executes Java code in the specified project's document, if any.
1723 1716 *
1724 1717 * @return true if code was executed.
  @@ -1737,17 +1730,6 @@
1737 1730 return true;
1738 1731 }
1739 1732
1740 - public static void main( String[] args )
1741 - throws Exception
1742 - {
1743 - Arguments arguments = new Arguments( args );
1744 - Scar scar = new Scar( arguments );
1745 - scar.initLoggerFactory();
1746 -
1747 - Project project = scar.project( arguments.get( "file", "." ) );
1748 - scar.build( project );
1749 - }
1750 -
1751 1733 /**
1752 1734 * List of project names that have been built. {@link #buildDependencies(Project)} will skip any projects with a matching name.
1753 1735 */
  @@ -1808,4 +1790,33 @@
1808 1790 return pProject;
1809 1791 }
1810 1792 }
1793 +
1794 + public static void main( String[] args )
1795 + throws Exception
1796 + {
1797 + Arguments arguments = new Arguments( args );
1798 + Scar scar = new Scar( arguments );
1799 + scar.initLoggerFactory();
1800 +
1801 + Project project = scar.project( arguments.get( "file", "." ) );
1802 + scar.build( project );
1803 + }
1804 +
1805 + /**
1806 + * Executes the buildDependencies, clean, compile, jar, and dist utility metshods.
1807 + */
1808 + public void build( Project project )
1809 + throws IOException
1810 + {
1811 + Util.assertNotNull( "Project", project );
1812 +
1813 + buildDependencies( project );
1814 + clean( project );
1815 + compile( project );
1816 + jar( project );
1817 + dist( project );
1818 +
1819 + builtProjects.add( project.get( "name" ) );
1820 + }
1821 +
1811 1822 }