From cbosdo at kemper.freedesktop.org Tue Apr 1 13:44:52 2014 From: cbosdo at kemper.freedesktop.org (Cédric Bosdonnat) Date: Tue, 1 Apr 2014 13:44:52 -0700 (PDT) Subject: [ooo-build-commit] ooeclipse: Branch 'master' Message-ID: <20140401204452.9944E76245@kemper.freedesktop.org> java/source/org/openoffice/ide/eclipse/java/export/JavaExportPart.java | 69 ++- java/source/org/openoffice/ide/eclipse/java/export/build.xml | 182 -------- java/source/org/openoffice/ide/eclipse/java/export/build.xml.tpl | 212 ++++++++++ java/source/org/openoffice/ide/eclipse/java/messages.properties | 1 4 files changed, 265 insertions(+), 199 deletions(-) New commits: commit a991733db00c6bcd95c8234ae6e0f95e633e2a1d Author: C??dric Bosdonnat Date: Tue Apr 1 22:40:00 2014 +0200 Generate an ant build file for exported projects diff --git a/java/source/org/openoffice/ide/eclipse/java/export/JavaExportPart.java b/java/source/org/openoffice/ide/eclipse/java/export/JavaExportPart.java index 69fcbb9..3c8dbd2 100644 --- a/java/source/org/openoffice/ide/eclipse/java/export/JavaExportPart.java +++ b/java/source/org/openoffice/ide/eclipse/java/export/JavaExportPart.java @@ -20,16 +20,23 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA - * + * * The Initial Developer of the Original Code is: C??dric Bosdonnat. * * Copyright: 2009 by C??dric Bosdonnat * * All Rights Reserved. - * + * ************************************************************************/ package org.openoffice.ide.eclipse.java.export; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Properties; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -41,14 +48,17 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.openoffice.ide.eclipse.core.PluginLogger; +import org.openoffice.ide.eclipse.core.model.IUnoidlProject; import org.openoffice.ide.eclipse.core.model.language.LanguageExportPart; import org.openoffice.ide.eclipse.core.wizards.pages.ManifestExportPage; import org.openoffice.ide.eclipse.java.Messages; +import org.openoffice.ide.eclipse.java.utils.TemplatesHelper; import org.openoffice.plugin.core.model.UnoPackage; /** * Dialog part for the Ant scripts export configuration. - * + * * @author C??dric Bosdonnat * */ @@ -60,38 +70,38 @@ public class JavaExportPart extends LanguageExportPart { private Text mNameRowTxt; private JavaExportPageControl mController; - + /** * {@inheritDoc} */ @Override public void createControls(Composite pParent) { - + mController = new JavaExportPageControl(); - + Label titleLbl = new Label( pParent, SWT.NONE ); titleLbl.setText( Messages.getString("JavaExportPart.Title") ); //$NON-NLS-1$ titleLbl.setLayoutData( new GridData( SWT.BEGINNING, SWT.BEGINNING, false, false ) ); - + Composite content = new Composite( pParent, SWT.NONE ); GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); gd.horizontalIndent = ManifestExportPage.HORIZONTAL_INDENT; content.setLayoutData( gd ); content.setLayout( new GridLayout() ); - + mSaveScripts = new Button( content, SWT.CHECK ); mSaveScripts.setText( Messages.getString("JavaExportPart.SaveAntScript") ); //$NON-NLS-1$ mSaveScripts.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, true, false ) ); mSaveScripts.addSelectionListener( new SelectionListener() { - + public void widgetSelected( SelectionEvent pE ) { - + mController.setSaveAntScript( mSaveScripts.getSelection() ); - + mNameRowLbl.setEnabled( mController.isSavePathEnabled() ); mNameRowTxt.setEnabled( mController.isSavePathEnabled() ); } - + public void widgetDefaultSelected( SelectionEvent pE ) { widgetSelected( pE ); } @@ -102,20 +112,20 @@ public class JavaExportPart extends LanguageExportPart { gd = new GridData( SWT.FILL, SWT.BEGINNING, true, false ); gd.horizontalIndent = ManifestExportPage.HORIZONTAL_INDENT; mNameRow.setLayoutData( gd ); - + mNameRowLbl = new Label( mNameRow, SWT.NONE ); mNameRowLbl.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false ) ); mNameRowLbl.setText( Messages.getString("JavaExportPart.AntFile") ); //$NON-NLS-1$ - + mNameRowTxt = new Text( mNameRow, SWT.BORDER | SWT.SINGLE ); mNameRowTxt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); mNameRowTxt.addModifyListener( new ModifyListener() { - + public void modifyText( ModifyEvent pEvent ) { mController.setSavePath( mNameRowTxt.getText() ); } }); - + // Load the default values mSaveScripts.setSelection( mController.isSavePathEnabled() ); mNameRowTxt.setText( mController.getSavePath() ); @@ -140,7 +150,32 @@ public class JavaExportPart extends LanguageExportPart { @Override public void doFinish( UnoPackage pModel ) { if ( mController.getSaveAntScript() ) { - // TODO Generate the build script + + // Generate the build script + IUnoidlProject unoProject = getPage().getProject(); + String prjName = unoProject.getName(); + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(unoProject.getName()); + + TemplatesHelper.copyTemplate( project, mController.getSavePath(), + JavaExportPart.class, new String( ), prjName ); + + // Generate the build.properties file + File dir = project.getFile(mController.getSavePath()).getLocation().toFile().getParentFile(); + File propsFile = new File(dir, "build.properties"); //$NON-NLS-1$ + FileWriter writer = null; + + try { + writer = new FileWriter(propsFile); + + Properties props = new Properties(); + props.put("office.install.dir", new String()); //$NON-NLS-1$ + props.put("sdk.dir", new String()); //$NON-NLS-1$ + props.put("java.debug", "false"); //$NON-NLS-1$ //$NON-NLS-2$ + props.store(writer, "This file can contain setup-dependent data, don't commit them!"); //$NON-NLS-1$ + writer.close(); + } catch ( IOException e ) { + PluginLogger.error( Messages.getString("JavaExportPart.BuildPropertiesError"), e ); //$NON-NLS-1$ + } } } } diff --git a/java/source/org/openoffice/ide/eclipse/java/export/build.xml b/java/source/org/openoffice/ide/eclipse/java/export/build.xml deleted file mode 100644 index 2e63008..0000000 --- a/java/source/org/openoffice/ide/eclipse/java/export/build.xml +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/source/org/openoffice/ide/eclipse/java/export/build.xml.tpl b/java/source/org/openoffice/ide/eclipse/java/export/build.xml.tpl new file mode 100644 index 0000000..cc99f03 --- /dev/null +++ b/java/source/org/openoffice/ide/eclipse/java/export/build.xml.tpl @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/source/org/openoffice/ide/eclipse/java/messages.properties b/java/source/org/openoffice/ide/eclipse/java/messages.properties index 8f4d8f2..9b802d7 100644 --- a/java/source/org/openoffice/ide/eclipse/java/messages.properties +++ b/java/source/org/openoffice/ide/eclipse/java/messages.properties @@ -4,6 +4,7 @@ Language.UnreadableOutputError=Unreadable output error Language.CreateCodeError=Code generation failed Language.GetClasspathError=Failed to get the project classpath JavaExportPart.AntFile=Ant build file +JavaExportPart.BuildPropertiesError=Error creating build.properties JavaExportPart.SaveAntScript=Save as Ant script JavaExportPart.Title=Java options JavaWizardPage.IncludeTestClasses=Include base classes for tests