33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-12-24 03:15:26 +00:00

creating project structure

This commit is contained in:
Daniel 2012-05-21 10:33:11 +02:00
commit 5c9cad0dc4
9 changed files with 761 additions and 0 deletions

View File

@ -0,0 +1,11 @@
build.version=dev
component.name=jedchecker
component.upperName=JEDCHECKER
; FTP Options
ftp.host=ftp.example.com
ftp.port=21
ftp.username=username
ftp.password=password
ftp.dir=/path/to/directory
ftp.mode=binary

173
builds/component.xml Normal file
View File

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Hotspots build file for Phing
written by Daniel Dimitrov - https://compojoom.com
Run "phing -f component.xml"
from the build directory to build the component, modules and plugins
-->
<project name="com_jedchecker" default="buildZip">
<property file="./build.properties"/>
<taskdef name="extfile" classname="phingext.listJPackageFilesTask"/>
<taskdef name="gitversion" classname="phingext.GitVersionTask"/>
<taskdef name="explode" classname="phingext.explodeTask"/>
<import file="plugin.xml" optional="true"/>
<import file="module.xml" optional="true"/>
<target name="setup-properties">
<!-- Initialize the version if it's not set -->
<tstamp>
<format property="build.date" pattern="%Y-%m-%d"/>
</tstamp>
<property name="dirs.root" value="${project.basedir}/../"/>
<property name="dirs.source" value="${dirs.root}source"/>
<if>
<equals arg1="${build.version}" arg2="dev"/>
<then>
<gitversion workingCopy="${dirs.root}" propertyName="git.lastrevision"/>
<property name="build.version" value="git_${git.lastrevision}" override="true"/>
</then>
</if>
<property name="destination.dir"
value="${dirs.root}/packages/components/com_${component.name}/com_${component.name}-${build.version}"/>
<mkdir dir="${destination.dir}"/>
<available file="${dirs.source}\administrator\components\com_${component.name}"
type="dir" property="admin.exist" value="yes"/>
<available file="${dirs.source}\administrator\language"
type="dir" property="adminLang.exist" value="yes"/>
<available file="${dirs.source}\components\com_${component.name}"
type="dir" property="frontend.exist" value="yes"/>
<available file="${dirs.source}\language"
type="dir" property="frontendLang.exist" value="yes"/>
<available file="${dirs.source}\media\com_${component.name}"
type="dir" property="media.exist" value="yes"/>
</target>
<target name="buildZip" depends="setup-properties, buildComponent">
<echo msg="buildZip"/>
<zip destfile="${destination.dir}/../com_${component.name}-${build.version}.zip"
basedir="${destination.dir}/../com_${component.name}-${build.version}"/>
</target>
<target name="buildComponent">
<copy todir="${destination.dir}/administrator/components/com_${component.name}">
<fileset dir="${dirs.source}/administrator/components/com_${component.name}">
<include name="**/*.*"/>
</fileset>
</copy>
<copy todir="${destination.dir}/">
<fileset dir="${dirs.source}/administrator/components/com_${component.name}">
<include name="${component.name}.xml"/>
<include name="script.php"/>
</fileset>
</copy>
<copy todir="${destination.dir}/administrator/language/">
<fileset dir="${dirs.source}/administrator/language/">
<include name="**/*.${component.name}.**"/>
</fileset>
</copy>
<copy todir="${destination.dir}/components/com_${component.name}">
<fileset dir="${dirs.source}/components/com_${component.name}" includes="**/*.*"/>
</copy>
<copy todir="${destination.dir}/language/">
<fileset dir="${dirs.source}/language/">
<include name="**/*.${component.name}.ini"/>
</fileset>
</copy>
<if>
<equals arg1="${media.exist}" arg2="1"/>
<then>
<copy todir="${destination.dir}/media/com_${component.name}">
<fileset dir="${dirs.source}/media/com_${component.name}">
<include name="**/*.*"/>
<exclude name="kml/*.*"/>
<include name="kml/index.html"/>
</fileset>
</copy>
</then>
</if>
<copy file="${dirs.source}/administrator/components/com_${component.name}/${component.name}.xml"
tofile="${destination.dir}/${component.name}.xml" overwrite="true">
<filterchain>
<replacetokens begintoken="@@" endtoken="@@">
<token key="DATE" value="${build.date}"/>
<token key="VERSION" value="${build.version}"/>
<token key="COMPONENTNAMEUPPERCASE" value="${component.upperName}"/>
<token key="COMPONENTNAME" value="${component.name}"/>
</replacetokens>
</filterchain>
</copy>
<copy file="${dirs.source}/administrator/components/com_${component.name}/script.php"
tofile="${destination.dir}/script.php" overwrite="true">
<filterchain>
<replacetokens begintoken="##" endtoken="##">
<token key="JEDCHECKER_VERSION" value="${build.version}"/>
</replacetokens>
</filterchain>
</copy>
<extfile file="${destination.dir}/${component.name}.xml"
sourceDir="${dirs.source}"
component="com_${component.name}"
/>
<if>
<isset property="plugins"/>
<then>
<foreach list="${plugins}" param="plugin" target="buildPlugin"/>
</then>
</if>
<if>
<isset property="modules_admin"/>
<then>
<foreach list="${modules_admin}" param="module_admin" target="buildModule"/>
</then>
</if>
</target>
<target name="dev-release" description="Makes everything except the documentation"
depends="buildZip, ftpdeploy">
</target>
<target name="ftpdeploy" depends="setup-properties">
<gitversion workingCopy="${dirs.root}" propertyName="git.lastrevision"/>
<!-- Core release -->
<echo>Uploading ${component.name} nightly build</echo>
<ftpdeploy
host="${ftp.host}"
port="${ftp.port}"
username="${ftp.username}"
password="${ftp.password}"
dir="${ftp.dir}/${component.name}/git${git.lastrevision}"
mode="${ftp.mode}"
level="debug">
<fileset dir="${dirs.root}">
<include name="CHANGELOG"/>
</fileset>
<fileset dir="${destination.dir}/../">
<include name="com_${component.name}-git_${git.lastrevision}.zip"/>
</fileset>
</ftpdeploy>
</target>
</project>

83
builds/module.xml Normal file
View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Generic build module
${module} should be mod_something...
-->
<project name="mod" default="buildModule">
<property name="admin_folder" value=""/>
<if>
<isset property="module_admin"/>
<then>
<property name="admin_folder" value="/administrator" override="true"/>
<property name="module" value="${module_admin}" override="true" />
</then>
</if>
<target name="buildModule">
<!--do we have a media folder?-->
<available file="${dirs.source}\media\${module}"
type="dir" property="mod.media.exist" value="yes"/>
<if>
<equals arg1="${adminLang.exist}" arg2="1"/>
<then>
<copy todir="${destination.dir}/administrator/modules/${module}/administrator/language/">
<fileset dir="${dirs.source}/administrator/language/">
<include name="**/*.${module}.**"/>
</fileset>
</copy>
</then>
</if>
<if>
<equals arg1="${frontendLang.exist}" arg2="1"/>
<then>
<copy todir="${destination.dir}/modules/${module}/language/">
<fileset dir="${dirs.source}/language/">
<include name="**/*.${module}.**"/>
</fileset>
</copy>
</then>
</if>
<copy todir="${destination.dir}${admin_folder}/modules/${module}">
<fileset dir="${dirs.source}${admin_folder}/modules/${module}" includes="**/*.*"/>
</copy>
<if>
<equals arg1="${mod.media.exist}" arg2="1"/>
<then>
<copy todir="${destination.dir}${admin_folder}/modules/${module}/media/${module}">
<fileset dir="${dirs.source}/media/${module}">
<include name="**/*.*"/>
<exclude name="kml/*.*"/>
</fileset>
</copy>
</then>
</if>
<copy file="${dirs.source}${admin_folder}/modules/${module}/${module}.xml"
tofile="${destination.dir}${admin_folder}/modules/${module}/${module}.xml" overwrite="true">
<filterchain>
<replacetokens begintoken="@@" endtoken="@@">
<token key="DATE" value="${build.date}"/>
<token key="VERSION" value="${build.version}"/>
<token key="MODULENAME" value="${module}"/>
</replacetokens>
</filterchain>
</copy>
<extfile file="${destination.dir}${admin_folder}/modules/${module}/${module}.xml"
sourceDir="${dirs.source}${admin_folder}/modules/${module}/"
component="${module}"
type="module"
/>
</target>
</project>

View File

@ -0,0 +1,55 @@
<?php
require_once 'phing/Task.php';
require_once 'phing/tasks/ext/svn/SvnBaseTask.php';
/**
* Git latest tree version to Phing property
* @package akeebabuilder
* @copyright Copyright (c)2009-2010 Nicholas K. Dionysopoulos
* @license GNU GPL version 3 or, at your option, any later version
* @author nicholas
*/
class GitVersionTask extends SvnBaseTask
{
private $propertyName = "git.version";
/**
* Sets the name of the property to use
*/
function setPropertyName($propertyName)
{
$this->propertyName = $propertyName;
}
/**
* Returns the name of the property to use
*/
function getPropertyName()
{
return $this->propertyName;
}
/**
* Sets the path to the working copy
*/
function setWorkingCopy($wc)
{
$this->workingCopy = $wc;
}
/**
* The main entry point
*
* @throws BuildException
*/
function main()
{
$this->setup('info');
exec('git log -n 1 --no-decorate --pretty=format:"%h" '.escapeshellarg(realpath($this->workingCopy)), $out);
$version = $out[0];
$this->project->setProperty($this->getPropertyName(), $version);
}
}

View File

@ -0,0 +1,56 @@
<?php
require_once "phing/Task.php";
class explodeTask extends Task
{
public function setString($string)
{
$this->string = $string;
}
public function setDelimiter($delimiter) {
$this->delimiter = $delimiter;
}
public function setKey($key) {
$this->key = $key;
}
/**
* Defines the name of a property to be set .
*
* @param string $name Name for the property to be set from input
*/
public function setPropertyName($name) {
$this->propertyName = $name;
}
/**
* The init method: Do init steps.
*/
public function init()
{
// nothing to do here
}
/**
* The main entry point method.
*/
public function main()
{
if ($this->propertyName === null) {
throw new BuildException("You must specify a value for propertyName attribute.");
}
$value = explode($this->delimiter, $this->string);
if ($value !== null) {
$this->project->setUserProperty($this->propertyName, $value[$this->key]);
}
}
}

View File

@ -0,0 +1,310 @@
<?php
require_once "phing/Task.php";
class listJPackageFilesTask extends Task
{
public $file;
public $type = 'component';
public function setType($type) {
$this->type = $type;
}
public function setFile($str)
{
$this->file = $str;
}
public function setSourceDir($dir)
{
$this->sourceDir = $dir;
}
public function setComponent($name)
{
$this->component = $name;
}
/**
* The init method: Do init steps.
*/
public function init()
{
// nothing to do here
}
/**
* The main entry point method.
*/
public function main()
{
$content = file_get_contents($this->file);
$content = preg_replace_callback('/##PACKAGEFILESPLUGIN##/', 'self::findPluginPackageFiles', $content);
if (preg_match('/##PACKAGEFILESMODULE##/', $content)) {
$content = preg_replace('/##PACKAGEFILESMODULE##/',
call_user_func('self::findModulePackageFiles'), $content);
}
if (preg_match('/##ADMINLANGUAGEFILES##/', $content)) {
$content = preg_replace('/##ADMINLANGUAGEFILES##/',
call_user_func('self::languageFiles', true), $content);
}
if (preg_match('/##FRONTENDLANGUAGEFILES##/', $content)) {
$content = preg_replace('/##FRONTENDLANGUAGEFILES##/',
call_user_func('self::languageFiles', false), $content);
}
if (preg_match('/##ADMINCOMPONENTPACKAGEFILES##/', $content)) {
$content = preg_replace('/##ADMINCOMPONENTPACKAGEFILES##/',
call_user_func('self::findComponentPackagefiles', true), $content);
}
if (preg_match('/##FRONTENDCOMPONENTPACKAGEFILES##/', $content)) {
$content = preg_replace('/##FRONTENDCOMPONENTPACKAGEFILES##/',
call_user_func('self::findComponentPackagefiles', false), $content);
}
if (preg_match('/##MEDIAPACKAGEFILES##/', $content)) {
$content = preg_replace('/##MEDIAPACKAGEFILES##/',
call_user_func('self::findMediaPackagefiles', false), $content);
}
file_put_contents($this->file, $content);
}
public function languageFiles($admin = false)
{
if($this->type == 'module') {
$this->sourceDir = $this->sourceDir . '/../../';
}
if($this->type == 'plugin') {
$this->sourceDir = $this->sourceDir . '/../../../';
}
$languageFolder = $this->sourceDir . '/language';
if ($admin) {
$languageFolder = $this->sourceDir . '/administrator/language';
}
$list = array();
if (file_exists($languageFolder)) {
$dir = new DirectoryIterator($languageFolder);
foreach ($dir as $element) {
if (!$element->isDot()) {
if ($element->isDir()) {
$langDir = new DirectoryIterator($element->getPath() . '/' . $element->getFileName());
foreach ($langDir as $langElement) {
if (!$langElement->isDot()) {
if ($langElement->isFile()) {
if ($this->component) {
// if(strstr($this->component,'sys'))
$name = explode('.', $langElement->getFileName());
$name = $name[1];
if ($name == $this->component) {
$list[] = '<language tag="' . $element->getFileName() . '">'
. $element->getFileName() . '/' . $langElement->getFileName() . '</language>';
}
}
// else {
// $list[] = '<language tag="' . $element->getFileName() . '">'
// . $element->getFileName() . '/' . $langElement->getFileName() . '</language>';
// }
// $packageMainFile = basename($this->file, '.xml');
// if ($element->getFileName() == $packageMainFile . '.php') {
// . $element->getFileName() . '/' . $langElement->getFileName() . '</language>';
}
}
}
}
}
}
} else {
echo 'Folder ' . $languageFolder . ' doesn\'t exist';
}
return implode("\n", $list);
}
public function findComponentPackagefiles($admin = false)
{
$list = array();
$componentFolder = $this->sourceDir . '/components/' . $this->component;
if ($admin) {
$componentFolder = $this->sourceDir . '/administrator/components/' . $this->component;
}
if (file_exists($componentFolder)) {
$dir = new DirectoryIterator($componentFolder);
foreach ($dir as $element) {
if (!$element->isDot()) {
if ($element->isDir()) {
$list[] = '<folder>' . $element->getFileName() . '</folder>';
}
if ($element->isFile()) {
$list[] = '<file>' . $element->getFileName() . '</file>';
}
}
}
} else {
echo 'Folder ' . $componentFolder . ' doesn\'t exist';
}
return implode("\n", $list);
}
public function findMediaPackagefiles()
{
$list = array();
$source = $this->sourceDir;
if(strstr($source, '/administrator/')) {
if($this->type == 'module') {
$source = $source . '..';
}
}
$mediaFolder = $source . '/media/' . $this->component;
if (file_exists($mediaFolder)) {
$dir = new DirectoryIterator($mediaFolder);
foreach ($dir as $element) {
if (!$element->isDot() && substr($element, 0, 1) != ".") {
if ($element->isDir()) {
$list[] = '<folder>' . $element->getFileName() . '</folder>';
}
if ($element->isFile()) {
$list[] = '<file>' . $element->getFileName() . '</file>';
}
}
}
} else {
echo 'Folder ' . $mediaFolder . ' doesn\'t exist';
}
return implode("\n", $list);
}
public function findPluginPackageFiles()
{
$list = array();
if (file_exists($this->sourceDir)) {
$dir = new DirectoryIterator($this->sourceDir);
foreach ($dir as $element) {
if (!$element->isDot()) {
if ($element->isDir()) {
$skip = false;
if ($element->getFileName() == 'administrator') {
/**
* we need to handle the language folder in the plugin
* differently. If the administrator folder contains
* just the language folder we don't need to list it.
* Otherwise when the user installs the plugin he will have
* administrator/language in his plugi folder which is lame...
*/
$adminDir = new DirectoryIterator($this->sourceDir . '/administrator');
$i = 0;
$language = false;
foreach ($adminDir as $adminElement) {
if ($adminElement->isDir() && !$adminElement->isDot()) {
if ($adminElement->getFileName() == 'language') {
$language = true;
}
$i++;
}
}
/**
* so we have just one folder and it is
* the language one???
*/
if ($i == 1 && $language == true) {
$skip = true;
}
}
if (!$skip) {
$list[] = '<folder>' . $element->getFileName() . '</folder>';
}
}
if ($element->isFile()) {
$packageMainFile = basename($this->file, '.xml');
if ($element->getFileName() == $packageMainFile . '.php') {
$list[] = '<file plugin="' . $packageMainFile . '">' . $element->getFilename() . '</file>';
} elseif ($element->getFileName() != basename($this->file)) {
$list[] = '<file>' . $element->getFileName() . '</file>';
}
}
}
}
} else {
echo 'Folder ' . $this->sourceDir . ' doesn\'t exist';
}
return implode("\n", $list);
}
public function findModulePackageFiles()
{
$list = array();
if (file_exists($this->sourceDir)) {
$dir = new DirectoryIterator($this->sourceDir);
foreach ($dir as $element) {
if (!$element->isDot()) {
if ($element->isDir()) {
$skip = false;
if ($element->getFileName() == 'administrator') {
/**
* we need to handle the language folder in the plugin
* differently. If the administrator folder contains
* just the language folder we don't need to list it.
* Otherwise when the user installs the plugin he will have
* administrator/language in his plugi folder which is lame...
*/
$adminDir = new DirectoryIterator($this->sourceDir . '/administrator');
$i = 0;
$language = false;
foreach ($adminDir as $adminElement) {
if ($adminElement->isDir() && !$adminElement->isDot()) {
if ($adminElement->getFileName() == 'language') {
$language = true;
}
$i++;
}
}
/**
* so we have just one folder and it is
* the language one???
*/
if ($i == 1 && $language == true) {
$skip = true;
}
}
if (!$skip) {
$list[] = '<folder>' . $element->getFileName() . '</folder>';
}
}
if ($element->isFile()) {
$packageMainFile = basename($this->file, '.xml');
if ($element->getFileName() == $packageMainFile . '.php') {
$list[] = '<file module="' . $packageMainFile . '">' . $element->getFilename() . '</file>';
} elseif ($element->getFileName() != basename($this->file)) {
$list[] = '<file>' . $element->getFileName() . '</file>';
}
}
}
}
} else {
echo 'Folder ' . $this->sourceDir . ' doesn\'t exist';
}
return implode("\n", $list);
}
}

65
builds/plugin.xml Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Generic build plugin
${plugin} should be mod_something...
-->
<project name="plugin" default="buildPlugin">
<target name="buildPlugin">
<explode propertyName="pluginType" string="${plugin}" delimiter="_" key="1" />
<explode propertyName="pluginName" string="${plugin}" delimiter="_" key="2" />
<!--do we have a media folder?-->
<available file="${dirs.source}\media\${plugin}"
type="dir" property="mod.media.exist" value="yes"/>
<if>
<equals arg1="${adminLang.exist}" arg2="1"/>
<then>
<copy todir="${destination.dir}/plugins/${pluginType}/${pluginName}/administrator/language/">
<fileset dir="${dirs.source}/administrator/language/">
<include name="**/*.${plugin}.**"/>
</fileset>
</copy>
</then>
</if>
<copy todir="${destination.dir}/plugins/${pluginType}/${pluginName}">
<fileset dir="${dirs.source}/plugins/${pluginType}/${pluginName}" includes="**/*.*"/>
</copy>
<if>
<equals arg1="${mod.media.exist}" arg2="1"/>
<then>
<copy todir="${destination.dir}/modules/${pluginType}/${pluginName}/media/${plugin}">
<fileset dir="${dirs.source}/media/${plugin}">
<include name="**/*.*"/>
<exclude name="kml/*.*"/>
</fileset>
</copy>
</then>
</if>
<copy file="${dirs.source}/plugins/${pluginType}/${pluginName}/${pluginName}.xml"
tofile="${destination.dir}/plugins/${pluginType}/${pluginName}/${pluginName}.xml" overwrite="true">
<filterchain>
<replacetokens begintoken="@@" endtoken="@@">
<token key="DATE" value="${build.date}"/>
<token key="VERSION" value="${build.version}"/>
<token key="PLUGINNAME" value="${plugin}"/>
</replacetokens>
</filterchain>
</copy>
<extfile file="${destination.dir}/plugins/${pluginType}/${pluginName}/${pluginName}.xml"
sourceDir="${dirs.source}/plugins/${pluginType}/${pluginName}"
component="${plugin}"
type="plugin"
/>
</target>
</project>

View File

@ -0,0 +1,8 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: Dq
* Date: 21/05/12
* Time: 10:26
* To change this template use File | Settings | File Templates.
*/