summaryrefslogtreecommitdiffstats
path: root/buildtools/ant
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools/ant')
-rw-r--r--buildtools/ant/Makefile.am21
-rw-r--r--buildtools/ant/README.dox8
-rw-r--r--buildtools/ant/antoptionswidget.ui173
-rw-r--r--buildtools/ant/antprojectpart.cpp608
-rw-r--r--buildtools/ant/antprojectpart.h117
-rw-r--r--buildtools/ant/classpathwidget.ui39
-rw-r--r--buildtools/ant/kdevantproject.desktop96
-rw-r--r--buildtools/ant/kdevantproject.rc14
8 files changed, 1076 insertions, 0 deletions
diff --git a/buildtools/ant/Makefile.am b/buildtools/ant/Makefile.am
new file mode 100644
index 00000000..6a92a5b1
--- /dev/null
+++ b/buildtools/ant/Makefile.am
@@ -0,0 +1,21 @@
+# Here resides the ant project part.
+
+INCLUDES = -I$(top_srcdir)/buildtools/lib/base \
+ -I$(top_srcdir)/buildtools/lib/widgets -I$(top_srcdir)/lib/interfaces \
+ -I$(top_srcdir)/lib/interfaces/extensions -I$(top_srcdir)/lib/util -I$(top_builddir)/buildtools/lib/widgets \
+ $(all_includes)
+
+kde_module_LTLIBRARIES = libkdevantproject.la
+libkdevantproject_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkdevantproject_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \
+ $(top_builddir)/buildtools/lib/widgets/libkdevbuildtoolswidgets.la $(top_builddir)/buildtools/lib/base/libkdevbuildbase.la
+
+libkdevantproject_la_SOURCES = antprojectpart.cpp antoptionswidget.ui classpathwidget.ui
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)
+service_DATA = kdevantproject.desktop
+
+rcdir = $(kde_datadir)/kdevantproject
+rc_DATA = kdevantproject.rc
diff --git a/buildtools/ant/README.dox b/buildtools/ant/README.dox
new file mode 100644
index 00000000..b4b8a7c9
--- /dev/null
+++ b/buildtools/ant/README.dox
@@ -0,0 +1,8 @@
+/** \class AntProjectPart
+ant build tool part.
+
+\authors <a href="mailto:mh AT caldera.de">Matthias Hoelzer-Kluepfel</a>
+
+\unmaintained This part is currently un-maintained
+
+*/
diff --git a/buildtools/ant/antoptionswidget.ui b/buildtools/ant/antoptionswidget.ui
new file mode 100644
index 00000000..fa78e97f
--- /dev/null
+++ b/buildtools/ant/antoptionswidget.ui
@@ -0,0 +1,173 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>AntOptionsWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>AntOptionsWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>410</width>
+ <height>266</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KComboBox" row="1" column="1">
+ <item>
+ <property name="text">
+ <string>Quiet</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Verbose</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Debug</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>Verbosity</cstring>
+ </property>
+ </widget>
+ <spacer row="3" column="2">
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>86</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>86</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Build file:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>BuildXML</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Verbosity:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>Verbosity</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Properties:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>Properties</cstring>
+ </property>
+ </widget>
+ <widget class="QTable" row="2" column="1" rowspan="1" colspan="2">
+ <column>
+ <property name="text">
+ <string>Property</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>Properties</cstring>
+ </property>
+ <property name="numRows">
+ <number>0</number>
+ </property>
+ <property name="numCols">
+ <number>2</number>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>240</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KURLRequester" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>BuildXML</cstring>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>BuildXML</tabstop>
+ <tabstop>Verbosity</tabstop>
+ <tabstop>Properties</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in implementation">kcombobox.h</include>
+ <include location="global" impldecl="in implementation">klineedit.h</include>
+ <include location="global" impldecl="in implementation">kpushbutton.h</include>
+ <include location="global" impldecl="in implementation">kdialog.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/buildtools/ant/antprojectpart.cpp b/buildtools/ant/antprojectpart.cpp
new file mode 100644
index 00000000..a7f0ea25
--- /dev/null
+++ b/buildtools/ant/antprojectpart.cpp
@@ -0,0 +1,608 @@
+#include "antprojectpart.h"
+
+#include <qapplication.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qpopupmenu.h>
+#include <qvbox.h>
+#include <qtable.h>
+#include <qtextstream.h>
+#include <qvaluestack.h>
+#include <qdir.h>
+
+
+#include <kdevgenericfactory.h>
+#include <kdebug.h>
+#include <kaction.h>
+#include <kpopupmenu.h>
+#include <kdialogbase.h>
+#include <klineedit.h>
+#include <kcombobox.h>
+#include <keditlistbox.h>
+#include <kurlrequester.h>
+
+#include <kdevplugininfo.h>
+
+#include <kdevcore.h>
+#include <kdevmakefrontend.h>
+#include <urlutil.h>
+
+
+#include "antoptionswidget.h"
+#include "classpathwidget.h"
+
+
+
+
+typedef KDevGenericFactory<AntProjectPart> AntProjectFactory;
+static const KDevPluginInfo data("kdevantproject");
+K_EXPORT_COMPONENT_FACTORY(libkdevantproject, AntProjectFactory( data ))
+
+
+AntOptions::AntOptions()
+ : m_buildXML("build.xml"), m_verbosity(AntOptions::Quiet)
+{
+}
+
+
+AntProjectPart::AntProjectPart(QObject *parent, const char *name, const QStringList &)
+ : KDevBuildTool(&data, parent, name ? name : "AntProjectPart")
+{
+ setInstance(AntProjectFactory::instance());
+
+ setXMLFile("kdevantproject.rc");
+
+ m_buildProjectAction = new KAction(i18n("&Build Project"), "make_kdevelop", Key_F8,
+ this, SLOT(slotBuild()),
+ actionCollection(), "build_build" );
+ m_buildProjectAction->setToolTip(i18n("Build project"));
+ m_buildProjectAction->setWhatsThis(i18n("<b>Build project</b><p>Executes <b>ant dist</b> command to build the project."));
+
+ KActionMenu *menu = new KActionMenu(i18n("Build &Target"),
+ actionCollection(), "build_target" );
+ menu->setToolTip(i18n("Build target"));
+ menu->setWhatsThis(i18n("<b>Build target</b><p>Executes <b>ant target_name</b> command to build the specified target."));
+
+ m_targetMenu = menu->popupMenu();
+
+ connect(m_targetMenu, SIGNAL(activated(int)), this, SLOT(slotTargetMenuActivated(int)));
+ connect(core(), SIGNAL(projectConfigWidget(KDialogBase*)), this, SLOT(projectConfigWidget(KDialogBase*)));
+ connect(core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), this, SLOT(contextMenu(QPopupMenu *, const Context *)));
+
+ m_antOptionsWidget = 0;
+}
+
+
+AntProjectPart::~AntProjectPart()
+{
+}
+
+
+void AntProjectPart::openProject(const QString &dirName, const QString &projectName)
+{
+ m_projectDirectory = dirName;
+ m_projectName = projectName;
+
+ QDomDocument &dom = *projectDom();
+ // Set the default directory radio to "executable"
+ /// \FIXME there is no kdevantproject so this will not work !
+ if (DomUtil::readEntry(dom, "/kdevantproject/run/directoryradio") == "" ) {
+ DomUtil::writeEntry(dom, "/kdevantproject/run/directoryradio", "executable");
+ }
+
+ /// @todo read alternative build file from properties
+ m_antOptions.m_buildXML = "build.xml";
+
+ parseBuildXML();
+
+ fillMenu();
+
+ QFile f(dirName + "/" + projectName.lower() + ".kdevelop" + ".filelist");
+ if (f.open(IO_ReadOnly))
+ {
+ QTextStream stream(&f);
+ while (!stream.atEnd())
+ {
+ QString s = stream.readLine();
+ if (!s.startsWith("#"))
+ m_sourceFiles << s;
+ }
+ }
+ else
+ populateProject();
+
+ KDevProject::openProject( dirName, projectName );
+}
+
+
+void AntProjectPart::populateProject()
+{
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ QValueStack<QString> s;
+ int prefixlen = m_projectDirectory.length()+1;
+ s.push(m_projectDirectory);
+
+ QDir dir;
+ do
+ {
+ dir.setPath(s.pop());
+ kdDebug() << "Examining: " << dir.path() << endl;
+ const QFileInfoList *dirEntries = dir.entryInfoList();
+ QPtrListIterator<QFileInfo> it(*dirEntries);
+ for (; it.current(); ++it)
+ {
+ QString fileName = it.current()->fileName();
+ if (fileName == "." || fileName == "..")
+ continue;
+ QString path = it.current()->absFilePath();
+ if (it.current()->isDir())
+ {
+ kdDebug() << "Pushing: " << path << endl;
+ s.push(path);
+ }
+ else
+ {
+ kdDebug() << "Adding: " << path << endl;
+ m_sourceFiles.append(path.mid(prefixlen));
+ }
+ }
+ }
+ while (!s.isEmpty());
+
+ QApplication::restoreOverrideCursor();
+}
+
+
+void AntProjectPart::closeProject()
+{
+ m_projectDirectory = "";
+ m_projectName = "";
+ m_buildProjectAction->setEnabled(false);
+
+ m_targetMenu->clear();
+
+ m_antOptions = AntOptions();
+
+ QFile f(m_projectDirectory + "/" + m_projectName.lower() + ".kdevelop" + ".filelist");
+ if (!f.open(IO_WriteOnly))
+ return;
+
+ QTextStream stream(&f);
+ stream << "# KDevelop Ant Project File List" << endl;
+
+ QStringList::ConstIterator it;
+ for (it = m_sourceFiles.begin(); it != m_sourceFiles.end(); ++it)
+ stream << (*it) << endl;
+ f.close();
+}
+
+
+QString AntProjectPart::projectDirectory() const
+{
+ return m_projectDirectory;
+}
+
+
+QString AntProjectPart::buildDirectory() const
+{
+ return m_projectDirectory;
+}
+
+QString AntProjectPart::projectName() const
+{
+ return m_projectName;
+}
+
+
+/** Retuns a PairList with the run environment variables */
+DomUtil::PairList AntProjectPart::runEnvironmentVars() const
+{
+ /// \FIXME there is no kdevantproject so this will not work !
+ return DomUtil::readPairListEntry(*projectDom(), "/kdevantproject/run/envvars", "envvar", "name", "value");
+}
+
+
+/** Retuns the currently selected run directory
+ * The returned string can be:
+ * if run/directoryradio == executable
+ * The directory where the executable is
+ * if run/directoryradio == build
+ * The directory where the executable is relative to build directory
+ * if run/directoryradio == custom
+ * The custom directory absolute path
+ */
+QString AntProjectPart::runDirectory() const
+{
+ return buildDirectory();
+ /// \FIXME put the code below into use!
+
+ QDomDocument &dom = *projectDom();
+
+ /// \FIXME there is no kdevantproject so this will not work !
+ QString directoryRadioString = DomUtil::readEntry(dom, "/kdevantproject/run/directoryradio");
+ QString DomMainProgram = DomUtil::readEntry(dom, "/kdevantproject/run/mainprogram");
+
+ if ( directoryRadioString == "build" )
+ return buildDirectory();
+
+ if ( directoryRadioString == "custom" )
+ return DomUtil::readEntry(dom, "/kdevantproject/run/customdirectory");
+
+ int pos = DomMainProgram.findRev('/');
+ if (pos != -1)
+ return buildDirectory() + "/" + DomMainProgram.left(pos);
+
+ return buildDirectory() + "/" + DomMainProgram;
+
+}
+
+
+/** Retuns the currently selected main program
+ * The returned string can be:
+ * if run/directoryradio == executable
+ * The executable name
+ * if run/directoryradio == build
+ * The path to executable relative to build directory
+ * if run/directoryradio == custom or relative == false
+ * The absolute path to executable
+ */
+QString AntProjectPart::mainProgram() const
+{
+ QDomDocument * dom = projectDom();
+
+ if ( !dom ) return QString();
+
+ QString DomMainProgram = DomUtil::readEntry( *dom, "/kdevantproject/run/mainprogram");
+
+ if ( DomMainProgram.isEmpty() ) return QString();
+
+ if ( DomMainProgram.startsWith("/") ) // assume absolute path
+ {
+ return DomMainProgram;
+ }
+ else // assume project relative path
+ {
+ return projectDirectory() + "/" + DomMainProgram;
+ }
+
+ return QString();
+}
+
+
+QString AntProjectPart::debugArguments() const
+{
+ return QString("");
+}
+
+/** Retuns a QString with the run command line arguments */
+QString AntProjectPart::runArguments() const
+{
+ /// \FIXME there is no kdevantproject so this will not work !
+ return DomUtil::readEntry(*projectDom(), "/kdevantproject/run/programargs");
+}
+
+
+QString AntProjectPart::activeDirectory() const
+{
+ /// \FIXME
+
+// return m_projectDirectory;
+
+ // returning m_projectDirectory is wrong, the path returned should be _relative_ to the project dir
+ // returning an empty string until antproject supports the idea of an active directory
+ return QString("");
+}
+
+
+QStringList AntProjectPart::allFiles() const
+{
+/* QStringList res;
+
+ QStringList::ConstIterator it;
+ for (it = m_sourceFiles.begin(); it != m_sourceFiles.end(); ++it)
+ {
+ QString fileName = *it;
+ if (!fileName.startsWith("/"))
+ {
+ fileName.prepend("/");
+ fileName.prepend(m_projectDirectory);
+ }
+ res += fileName;
+ }
+
+ return res;*/
+
+ // return all files relative to the project directory!
+ return m_sourceFiles;
+}
+
+
+void AntProjectPart::addFile(const QString &fileName)
+{
+ QStringList fileList;
+ fileList.append ( fileName );
+
+ this->addFiles ( fileList );
+}
+
+void AntProjectPart::addFiles ( const QStringList& fileList )
+{
+ QStringList::ConstIterator it;
+
+ for ( it = fileList.begin(); it != fileList.end(); ++it )
+ {
+ m_sourceFiles.append (*it );
+ }
+
+ kdDebug() << "Emitting addedFilesToProject" << endl;
+ emit addedFilesToProject(fileList);
+}
+
+void AntProjectPart::removeFile(const QString &fileName)
+{
+ QStringList fileList;
+ fileList.append ( fileName );
+
+ this->removeFiles ( fileList );
+}
+
+void AntProjectPart::removeFiles ( const QStringList& fileList )
+{
+ kdDebug() << "Emitting removedFilesFromProject" << endl;
+ emit removedFilesFromProject(fileList);
+
+ QStringList::ConstIterator it;
+
+ for ( it = fileList.begin(); it != fileList.end(); ++it )
+ {
+ m_sourceFiles.remove ( *it );
+ }
+}
+
+void AntProjectPart::parseBuildXML()
+{
+ m_antOptions.m_targets.clear();
+ m_antOptions.m_properties.clear();
+ m_antOptions.m_defineProperties.clear();
+
+ // open build file
+ QFile bf(m_projectDirectory + "/" + m_antOptions.m_buildXML);
+ if (!bf.open(IO_ReadOnly))
+ return;
+
+ // parse build file
+ QDomDocument dom;
+ if (!dom.setContent(&bf))
+ {
+ bf.close();
+ return;
+ }
+ bf.close();
+
+ m_projectName = dom.documentElement().attribute("name", m_projectName);
+ m_antOptions.m_defaultTarget = dom.documentElement().attribute("default", "");
+
+ QDomNode node = dom.documentElement().firstChild();
+ while (!node.isNull())
+ {
+ if (node.toElement().tagName() == "target")
+ {
+ if (m_antOptions.m_defaultTarget.isEmpty())
+ m_antOptions.m_defaultTarget = node.toElement().attribute("name");
+ m_antOptions.m_targets.append(node.toElement().attribute("name"));
+ }
+ else if (node.toElement().tagName() == "property")
+ {
+ m_antOptions.m_properties.insert(node.toElement().attribute("name"), node.toElement().attribute("value"));
+ m_antOptions.m_defineProperties.insert(node.toElement().attribute("name"), false);
+ }
+
+ /// @todo Handle property files
+ /// @todo evaluate properties' values
+
+ node = node.nextSibling();
+ }
+}
+
+
+void AntProjectPart::fillMenu()
+{
+ m_buildProjectAction->setEnabled(!m_antOptions.m_defaultTarget.isEmpty());
+
+ m_targetMenu->clear();
+ int id = 0;
+ QStringList::ConstIterator it;
+ for (it = m_antOptions.m_targets.begin(); it != m_antOptions.m_targets.end(); ++it)
+ m_targetMenu->insertItem(*it, id++);
+}
+
+
+void AntProjectPart::slotBuild()
+{
+ ant(m_antOptions.m_defaultTarget);
+}
+
+
+void AntProjectPart::slotTargetMenuActivated(int id)
+{
+ ant(m_antOptions.m_targets[id]);
+}
+
+
+void AntProjectPart::ant(const QString &target)
+{
+ QString cmd = "%0 cd %1 && ant %2 -buildfile %3 %4 %5";
+
+ QString verb = "";
+ switch (m_antOptions.m_verbosity)
+ {
+ case AntOptions::Quiet:
+ verb = "-quiet";
+ break;
+ case AntOptions::Verbose:
+ verb = "-verbose";
+ break;
+ default:
+ verb = "-debug";
+ break;
+ }
+
+ QString options = "";
+ QMap<QString,QString>::Iterator it;
+ for (it = m_antOptions.m_properties.begin(); it != m_antOptions.m_properties.end(); ++it)
+ if (m_antOptions.m_defineProperties[it.key()])
+ options += "-D" + it.key() + "=\"" + it.data() + "\" ";
+
+ QString cp;
+ if (!m_classPath.count() == 0)
+ cp = "CLASSPATH="+m_classPath.join(":");
+
+ makeFrontend()->queueCommand(m_projectDirectory, cmd.arg(cp).arg(m_projectDirectory).arg(target).arg(m_antOptions.m_buildXML).arg(verb).arg(options));
+}
+
+
+void AntProjectPart::projectConfigWidget(KDialogBase *dlg)
+{
+ QVBox *vbox = dlg->addVBoxPage(i18n("Ant Options"));
+ m_antOptionsWidget = new AntOptionsWidget(vbox);
+
+ m_antOptionsWidget->BuildXML->setURL(m_antOptions.m_buildXML);
+
+ switch (m_antOptions.m_verbosity)
+ {
+ case AntOptions::Quiet:
+ m_antOptionsWidget->Verbosity->setCurrentItem(0);
+ break;
+ case AntOptions::Verbose:
+ m_antOptionsWidget->Verbosity->setCurrentItem(1);
+ break;
+ default:
+ m_antOptionsWidget->Verbosity->setCurrentItem(2);
+ break;
+ }
+
+ m_antOptionsWidget->Properties->setNumRows(m_antOptions.m_properties.count());
+ m_antOptionsWidget->Properties->setNumCols(2);
+
+ QMap<QString,QString>::Iterator it;
+ int i=0;
+ for (it = m_antOptions.m_properties.begin(); it != m_antOptions.m_properties.end(); ++it)
+ {
+ QCheckTableItem *citem = new QCheckTableItem(m_antOptionsWidget->Properties, it.key());
+ citem->setChecked(m_antOptions.m_defineProperties[it.key()]);
+ m_antOptionsWidget->Properties->setItem(i,0, citem);
+ QTableItem *item = new QTableItem(m_antOptionsWidget->Properties, QTableItem::WhenCurrent, it.data());
+ m_antOptionsWidget->Properties->setItem(i,1, item);
+ ++i;
+ }
+
+ connect(dlg, SIGNAL(okClicked()), this, SLOT(optionsAccepted()));
+
+ vbox = dlg->addVBoxPage(i18n("Classpath"));
+ m_classPathWidget = new ClassPathWidget(vbox);
+
+ m_classPathWidget->ClassPath->insertStringList(m_classPath);
+}
+
+
+void AntProjectPart::optionsAccepted()
+{
+ if (!m_antOptionsWidget || !m_classPathWidget)
+ return;
+
+ m_antOptions.m_buildXML = m_antOptionsWidget->BuildXML->url();
+
+ switch (m_antOptionsWidget->Verbosity->currentItem())
+ {
+ case 1:
+ m_antOptions.m_verbosity = AntOptions::Verbose;
+ break;
+ case 2:
+ m_antOptions.m_verbosity = AntOptions::Debug;
+ break;
+ default:
+ m_antOptions.m_verbosity = AntOptions::Quiet;
+ break;
+ }
+
+ for (int i=0; i<m_antOptionsWidget->Properties->numRows(); ++i)
+ {
+ QString key = m_antOptionsWidget->Properties->text(i,0);
+ m_antOptions.m_properties.replace(key, m_antOptionsWidget->Properties->text(i,1));
+ kdDebug() << "PROP: " << key << " = " << m_antOptionsWidget->Properties->text(i,1);
+
+ QCheckTableItem *item =(QCheckTableItem*) m_antOptionsWidget->Properties->item(i,0);
+ m_antOptions.m_defineProperties.replace(key, item->isChecked());
+ }
+
+ m_classPath = m_classPathWidget->ClassPath->items();
+
+ m_antOptionsWidget = 0;
+ m_classPathWidget = 0;
+}
+
+
+void AntProjectPart::contextMenu(QPopupMenu *popup, const Context *context)
+{
+ if (!context->hasType( Context::FileContext ))
+ return;
+
+ const FileContext *fcontext = static_cast<const FileContext*>(context);
+ KURL url = fcontext->urls().first();
+ if (URLUtil::isDirectory(url))
+ return;
+
+ m_contextFileName = url.fileName();
+ bool inProject = project()->allFiles().contains(m_contextFileName.mid ( project()->projectDirectory().length() + 1 ) );
+ QString popupstr = QFileInfo(m_contextFileName).fileName();
+ if (m_contextFileName.startsWith(projectDirectory()+ "/"))
+ m_contextFileName.remove(0, projectDirectory().length()+1);
+
+ popup->insertSeparator();
+ if (inProject)
+ {
+ int id = popup->insertItem( i18n("Remove %1 From Project").arg(popupstr),
+ this, SLOT(slotRemoveFromProject()) );
+ popup->setWhatsThis(id, i18n("<b>Remove from project</b><p>Removes current file from the project."));
+ }
+ else
+ {
+ int id = popup->insertItem( i18n("Add %1 to Project").arg(popupstr),
+ this, SLOT(slotAddToProject()) );
+ popup->setWhatsThis(id, i18n("<b>Add to project</b><p>Adds current file from the project."));
+ }
+}
+
+
+void AntProjectPart::slotAddToProject()
+{
+ QStringList fileList;
+ fileList.append ( m_contextFileName );
+ addFiles ( fileList );
+}
+
+
+void AntProjectPart::slotRemoveFromProject()
+{
+ QStringList fileList;
+ fileList.append ( m_contextFileName );
+ removeFiles ( fileList );
+}
+
+
+#include "antprojectpart.moc"
+
+
+/*!
+ \fn AntProjectPart::distFiles() const
+ */
+QStringList AntProjectPart::distFiles() const
+{
+ QStringList sourceList = allFiles();
+ // Scan current source directory for any .pro files.
+ QString projectDir = projectDirectory();
+ QDir dir(projectDir);
+ QStringList files = dir.entryList( "build.xml");
+ return sourceList + files;
+}
diff --git a/buildtools/ant/antprojectpart.h b/buildtools/ant/antprojectpart.h
new file mode 100644
index 00000000..d6540c48
--- /dev/null
+++ b/buildtools/ant/antprojectpart.h
@@ -0,0 +1,117 @@
+#ifndef _ANTPROJECTPART_H_
+#define _ANTPROJECTPART_H_
+
+
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qmap.h>
+
+
+class QPopupMenu;
+
+
+class KAction;
+class KDialogBase;
+class Context;
+class ClassPathWidget;
+
+
+#include "kdevbuildtool.h"
+
+
+class AntOptionsWidget;
+
+
+class AntOptions
+{
+public:
+
+ AntOptions();
+
+ enum Verbosity { Quiet, Verbose, Debug };
+
+ QString m_buildXML;
+ QString m_defaultTarget;
+ QStringList m_targets;
+ QMap<QString,QString> m_properties;
+ QMap<QString,bool> m_defineProperties;
+ Verbosity m_verbosity;
+
+};
+
+
+class AntProjectPart : public KDevBuildTool
+{
+ Q_OBJECT
+
+public:
+
+ AntProjectPart(QObject *parent, const char *name, const QStringList &args);
+ ~AntProjectPart();
+ QStringList distFiles() const;
+
+
+protected:
+
+ virtual void openProject(const QString &dirName, const QString &projectName);
+ virtual void closeProject();
+
+ virtual QString projectDirectory() const;
+ virtual QString projectName() const;
+ virtual QString mainProgram() const;
+ virtual QString activeDirectory() const;
+ virtual QStringList allFiles() const;
+ virtual QString buildDirectory() const;
+ virtual QString runDirectory() const;
+ virtual QString runArguments() const;
+ virtual QString debugArguments() const;
+ virtual DomUtil::PairList runEnvironmentVars() const;
+
+ virtual void addFile(const QString &fileName);
+ virtual void addFiles ( const QStringList &fileList );
+ virtual void removeFile(const QString &fileName);
+ virtual void removeFiles ( const QStringList& fileList );
+
+
+private slots:
+
+ void slotBuild();
+ void slotTargetMenuActivated(int id);
+
+ void projectConfigWidget(KDialogBase *dlg);
+ void contextMenu(QPopupMenu *popup, const Context *context);
+
+ void optionsAccepted();
+
+ void slotAddToProject();
+ void slotRemoveFromProject();
+
+
+private:
+
+ void parseBuildXML();
+ void fillMenu();
+ void populateProject();
+
+ void ant(const QString &target);
+
+ QString m_projectDirectory, m_projectName;
+ QStringList m_classPath;
+
+ QStringList m_sourceFiles;
+
+ AntOptions m_antOptions;
+
+ KAction *m_buildProjectAction;
+
+ QPopupMenu *m_targetMenu;
+
+ AntOptionsWidget *m_antOptionsWidget;
+ ClassPathWidget *m_classPathWidget;
+
+ QString m_contextFileName;
+
+};
+
+
+#endif
diff --git a/buildtools/ant/classpathwidget.ui b/buildtools/ant/classpathwidget.ui
new file mode 100644
index 00000000..8bfde971
--- /dev/null
+++ b/buildtools/ant/classpathwidget.ui
@@ -0,0 +1,39 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>ClassPathWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ClassPathWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>471</width>
+ <height>288</height>
+ </rect>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KEditListBox">
+ <property name="name">
+ <cstring>ClassPath</cstring>
+ </property>
+ <property name="title">
+ <string>Class&amp;path</string>
+ </property>
+ </widget>
+ </hbox>
+</widget>
+<includes>
+ <include location="global" impldecl="in implementation">keditlistbox.h</include>
+ <include location="global" impldecl="in implementation">kdialog.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>keditlistbox.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/buildtools/ant/kdevantproject.desktop b/buildtools/ant/kdevantproject.desktop
new file mode 100644
index 00000000..231339ea
--- /dev/null
+++ b/buildtools/ant/kdevantproject.desktop
@@ -0,0 +1,96 @@
+[Desktop Entry]
+Type=Service
+Exec=blubb
+Comment=Ant Project
+Comment[br]=Raktres Ant
+Comment[ca]=Projecte Ant
+Comment[cs]=Ant projekt
+Comment[da]=Ant-projekt
+Comment[de]=Ant-Projekt für KDevelop
+Comment[el]=Έργο Ant
+Comment[es]=Proyecto Ant
+Comment[et]=Ant projekt
+Comment[eu]=Ant proiektua
+Comment[fa]=پروژۀ Ant
+Comment[fr]=Projet avec Ant
+Comment[ga]=Comhad tionscadail Ant
+Comment[gl]=Proxecto Ant
+Comment[hi]=एएनटी परियोजना
+Comment[hu]=Ant-projekt
+Comment[is]=Ant verkefni
+Comment[it]=Progetto Ant
+Comment[ja]=Ant プロジェクト
+Comment[ms]=Projek Ant
+Comment[nds]=Ant-Projekt
+Comment[ne]=एन्ट परियोजना
+Comment[nl]=Ant-project
+Comment[pa]=Ant ਪ੍ਰੋਜੈਕਟ
+Comment[pl]=Projekt: Ant
+Comment[pt]=Projecto Ant
+Comment[pt_BR]=Projeto Ant
+Comment[ru]=Проект Ant
+Comment[sk]=Ant projekt
+Comment[sl]=Projekt Ant
+Comment[sr]=Ant пројекат
+Comment[sr@Latn]=Ant projekat
+Comment[sv]=Ant-projekt
+Comment[ta]=ஆன்ட்பிராஜக்ட்
+Comment[tg]=Лоиҳаи Ant
+Comment[tr]=Ant Projesi
+Comment[uz]=Ant loyihasi
+Comment[uz@cyrillic]=Ant лойиҳаси
+Comment[zh_CN]=Ant 工程
+Comment[zh_TW]=Ant 專案
+Name=KDevAntProject
+Name[da]=KDevelop Ant-projekt
+Name[de]=Ant-Projekt (KDevelop)
+Name[hi]=के-डेव-एएनटी-परियोजना
+Name[nds]=Ant-Projekt (KDevelop)
+Name[ne]=केडीई विकास एन्ट परियोजना
+Name[pl]=KDevProjektAnt
+Name[sk]=KDevAntProjekt
+Name[sv]=KDevelop Ant-projekt
+Name[ta]=கெடெவ்ஆன்ட் பிராஜக்ட்
+Name[tg]=Лоиҳаи KDevAnt
+Name[zh_TW]=KDevelop Ant 專案
+GenericName=Ant Project
+GenericName[br]=Raktres Ant
+GenericName[ca]=Projecte Ant
+GenericName[da]=Ant-projekt
+GenericName[de]=Ant-Projekt
+GenericName[el]=Έργο Ant
+GenericName[es]=Proyecto Ant
+GenericName[et]=Ant projekt
+GenericName[eu]=Ant proiektua
+GenericName[fa]=پروژۀ Ant
+GenericName[fr]=Projet avec Ant
+GenericName[ga]=Comhad tionscadail Ant
+GenericName[gl]=Proxecto Ant
+GenericName[hi]=एएनटी परियोजना
+GenericName[hu]=Ant-projekt
+GenericName[it]=Project con Ant
+GenericName[ja]=Ant プロジェクト
+GenericName[ms]=Projek Ant
+GenericName[nds]=Ant-Projekt
+GenericName[ne]=एन्ट परियोजना
+GenericName[nl]=Ant-project
+GenericName[pl]=Projekt: Ant
+GenericName[pt]=Projecto Ant
+GenericName[pt_BR]=Projeto Ant
+GenericName[ru]=Проект Ant
+GenericName[sk]=Ant projekt
+GenericName[sl]=Projekt Ant
+GenericName[sr]=Ant пројекат
+GenericName[sr@Latn]=Ant projekat
+GenericName[sv]=Ant-projekt
+GenericName[ta]=ஆன்ட்பிராஜக்ட்
+GenericName[tg]=Лоиҳаи Ant
+GenericName[tr]=Ant Projesi
+GenericName[uz]=Ant loyihasi
+GenericName[uz@cyrillic]=Ant лойиҳаси
+GenericName[zh_CN]=Ant 工程
+GenericName[zh_TW]=Ant 專案
+ServiceTypes=KDevelop/Project
+X-KDE-Library=libkdevantproject
+X-KDevelop-Version=5
+X-KDevelop-Args=
diff --git a/buildtools/ant/kdevantproject.rc b/buildtools/ant/kdevantproject.rc
new file mode 100644
index 00000000..df892b3c
--- /dev/null
+++ b/buildtools/ant/kdevantproject.rc
@@ -0,0 +1,14 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="KDevAntProject" version="2">
+<MenuBar>
+ <Menu name="build" >
+ <Action name="build_build" />
+<!-- <Action name="build_compilefile" /> -->
+ <Action name="build_target" />
+<!-- <Action name="build_clean" />
+ <Separator/>
+ <Action name="build_execute" /> -->
+ </Menu>
+</MenuBar>
+</kpartgui>
+