Skip to content

Commit

Permalink
Remove cobertura and sonar completely. Ref OFBIZ-6783
Browse files Browse the repository at this point in the history
After getting consensus from the community in the email thread below
we agreed to remove these two items because they make the startup
logic more complex and also because many things are broken and 
unmaintained for years.

It is a good idea to reintroduce cobertura in the future on a cleaner
implementation, hopefully completely away from the start component and
perhaps as a container implementation.

The email thread:
http://ofbiz.markmail.org/message/b4jovfhurczunbam?q=remove+cobertura

The related JIRA:
https://issues.apache.org/jira/browse/OFBIZ-6783


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1746236 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pythys committed May 31, 2016
1 parent 48828d2 commit ca819dd
Show file tree
Hide file tree
Showing 16 changed files with 3 additions and 692 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<classpathentry kind="src" path="applications/humanres/src"/>
<classpathentry kind="src" path="applications/workeffort/src"/>
<classpathentry kind="src" path="framework/base/config"/>
<classpathentry excluding="org/ofbiz/base/config/CoberturaInstrumenter.java" kind="src" path="framework/base/src"/>
<classpathentry kind="src" path="framework/base/src"/>
<classpathentry kind="src" path="framework/catalina/src"/>
<classpathentry kind="src" path="framework/common/src"/>
<classpathentry kind="src" path="framework/datafile/src"/>
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
applications/*/build
framework/*/build
framework/base/lib/cobertura-*.jar
framework/base/lib/asm*.jar
framework/base/lib/oro*.jar
framework/entity/lib/jdbc/*.jar
Expand All @@ -16,9 +15,6 @@ runtime/SvnInfo.ftl
runtime/GitInfo.ftl
runtime/test-list-build.xml
runtime/logs/access_log.*
runtime/logs/cobertura-base.dat
runtime/logs/cobertura-components.dat
runtime/logs/cobertura-report
runtime/logs/*.log*
runtime/logs/*.html*
runtime/logs/test-results/*
Expand Down
134 changes: 1 addition & 133 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ under the License.
-->

<project name="OFBiz Main Build" default="build" basedir="."
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:sonar="antlib:org.sonar.ant:sonar">
xmlns:ivy="antlib:org.apache.ivy.ant">

<taskdef uri="antlib:org.apache.ivy.ant" resource="org/apache/ivy/ant/antlib.xml">
<classpath>
Expand Down Expand Up @@ -66,14 +65,6 @@ under the License.
<copy file="runtime/data/derby.properties" todir="runtime/data/derby"/>
</target>

<target name="sonar-init">
<taskdef uri="antlib:org.sonar.ant:sonar" resource="org/sonar/ant/antlib.xml">
<classpath>
<pathelement location="framework/base/lib/sonar-ant-task-1.3.jar" />
</classpath>
</taskdef>
</target>

<!-- ================================================================== -->
<!-- Removes all created files and directories -->
<!-- ================================================================== -->
Expand Down Expand Up @@ -103,8 +94,6 @@ under the License.
<target name="clean-downloads"
description="Clean all downloaded files">
<delete verbose="true" deleteonexit="true">
<fileset dir="framework/base/lib" includes="cobertura-*.jar"/>
<fileset dir="framework/base/lib" includes="sonar-*.jar"/>
<fileset dir="framework/base/lib" includes="activemq-*.jar"/>
<fileset dir="framework/entity/lib/jdbc" includes="postgresql-*.jar"/>
<fileset dir="framework/entity/lib/jdbc" includes="mysql-*.jar"/>
Expand Down Expand Up @@ -1210,9 +1199,6 @@ under the License.
</fail>
</target>

<target name="run-tests-with-cobertura" depends="download-cobertura, run-tests"
description="Download Cobertura and perform code coverage (same as run-tests). You will need a valid Internet connection to download cobertura"/>

<target name="_check-separated-tests-already-setup">
<available file="runtime/test-list-build.xml" property="_separated-tests-already-setup"/>
</target>
Expand Down Expand Up @@ -1310,116 +1296,6 @@ under the License.
<ant antfile="runtime/test-list-build.xml" target="all-tests"/>
</target>

<target name="cobertura-report"
description="Generate a HTML code coverage report with cobertura, can be found in runtime/logs/cobertura-report">
<delete dir="runtime/logs/cobertura-report"/>
<mkdir dir="runtime/logs/cobertura-report"/>
<taskdef resource="tasks.properties">
<classpath>
<fileset dir="framework/base/lib">
<include name="cobertura-1.9.4.1.jar" />
<include name="log4j-1.2.17.jar" />
<include name="scripting/asm*.jar" />
<include name="scripting/jakarta-oro-2.0.8.jar" />
</fileset>
</classpath>
</taskdef>
<cobertura-merge datafile="runtime/logs/cobertura.dat">
<fileset dir="runtime/logs">
<include name="cobertura-base.dat"/>
<include name="cobertura-components.dat"/>
</fileset>
</cobertura-merge>
<cobertura-report datafile="runtime/logs/cobertura.dat" destdir="runtime/logs/cobertura-report">
<dirset dir=".">
<include name="*/*/src"/>
</dirset>

<include name="**/*.java"/>
</cobertura-report>
</target>

<target name="cobertura-report-xml" depends="_setup-separated-test-run"
description="Generate a XML file from the cobertura report, this will be used by sonar">
<delete dir="runtime/logs/cobertura-report"/>
<mkdir dir="runtime/logs/cobertura-report"/>
<taskdef resource="tasks.properties">
<classpath>
<fileset dir="framework/base/lib">
<include name="cobertura-1.9.4.1.jar" />
<include name="log4j-1.2.17.jar" />
<include name="scripting/asm*.jar" />
<include name="scripting/jakarta-oro-2.0.8.jar" />
</fileset>
</classpath>
</taskdef>
<cobertura-merge datafile="runtime/logs/cobertura.dat">
<fileset dir="runtime/logs">
<include name="cobertura-base.dat"/>
<include name="cobertura-components.dat"/>
</fileset>
</cobertura-merge>
<cobertura-report format="xml" datafile="runtime/logs/cobertura.dat" destdir="runtime/logs/cobertura-report">
<dirset dir=".">
<include name="*/*/src"/>
</dirset>
<include name="**/*.java"/>
</cobertura-report>
</target>

<target name="sonar" depends="download-sonar-ant-task, sonar-init"
description="Sonar code analysis. You need a Sonar instance running to use it. More info on http://www.sonarsource.org/">
<exec executable="svn" dir="." output="runtime/svninfo_tmp.xml">
<arg value="info"/>
<arg value="--xml"/>
</exec>
<xmlproperty file="runtime/svninfo_tmp.xml"/>

<property name="sonar.sources" value="framework/base/src, framework/bi/src,
framework/catalina/src, framework/common/src, framework/datafile/src, framework/entity/src, framework/entityext/src,
framework/example/src, framework/geronimo/src,
framework/minilang/src, framework/security/src, framework/service/src, framework/start/src,
framework/testtools/src, framework/webapp/src, framework/webtools/src, framework/widget/src,
applications/accounting/src, applications/commonext/src, applications/content/src, applications/humanres/src,
applications/manufacturing/src, applications/marketing/src, applications/order/src, applications/party/src,
applications/product/src, applications/securityext/src, applications/workeffort/src, specialpurpose/assetmaint/src,
specialpurpose/ebay/src, specialpurpose/ebaystore/src, specialpurpose/ecommerce/src, specialpurpose/googlebase/src,
specialpurpose/googlecheckout/src, specialpurpose/hhfacility/src, specialpurpose/oagis/src, specialpurpose/pos/src,
specialpurpose/scrum/src, specialpurpose/birt/src" />
<property name="sonar.tests" value="framework/base/src/org/ofbiz/base/test, framework/entity/src/org/ofbiz/entity/test,
framework/service/src/org/ofbiz/service/test,
applications/accounting/src/org/ofbiz/accounting/test, applications/content/src/org/ofbiz/content/test,
applications/product/src/org/ofbiz/product/test, applications/product/src/org/ofbiz/shipment/test,
applications/securityext/src/org/ofbiz/securityext/test" />

<!-- list of optional Sonar properties -->
<property name="sonar.projectName" value="Apache OFBiz" />
<sonar:sonar key="org.apache:ofbiz" version="${info.entry.commit(revision)}" xmlns:sonar="antlib:org.sonar.ant:sonar"/>
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="sonar.cobertura.reportPath" value="runtime/logs/cobertura-report/coverage.xml"/>
<property name="sonar.java.source" value="1.8" />
<property name="sonar.java.target" value="1.8" />
<!-- default for jdbc url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8-->
<property name="sonar.jdbc.url" value="${sonar.jdbc.url}"/>
<property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" />
<property name="sonar.jdbc.username" value="${sonar.jdbc.username}" />
<property name="sonar.jdbc.password" value="${sonar.jdbc.password}" />

<!-- SERVER ON A REMOTE HOST -->
<property name="sonar.host.url" value="${sonar.host.url}" />
</target>

<target name="full-sonar">
<antcall target="clean-all"/>
<antcall target="load-demo"/>
<antcall target="download-cobertura"/>
<antcall target="run-tests">
<param name="-portoffset" value="${portoffset}"/>
</antcall>
<antcall target="cobertura-report-xml"/>
<antcall target="sonar"/>
</target>

<!-- ================================================================== -->
<!-- Ivy targets, more info at http://ant.apache.org/ivy/ -->
<!-- ================================================================== -->
Expand All @@ -1434,21 +1310,13 @@ under the License.
<echo>Please check that this version is appropriate for you!</echo>
</target>

<target name="download-cobertura" description="Download cobertura related files">
<ivy:retrieve pattern="framework/base/lib/[artifact]-[revision].[ext]" conf="cobertura"/>
</target>

<target name="download-PG-JDBC" description="Download postgres jdbc driver">
<ivy:retrieve pattern="framework/entity/lib/jdbc/[artifact]-[revision].[ext]" conf="postgres"/>
<echo> </echo>
<echo>======================================================</echo>
<echo>Please check that this version is appropriate for you!</echo>
</target>

<target name="download-sonar-ant-task" description="Download sonar related files">
<ivy:retrieve pattern="framework/base/lib/[artifact]-[revision].[ext]" conf="sonar-ant-task"/>
</target>

<target name="download-mySQL-JDBC" description="Download mySQL jdbc driver">
<ivy:retrieve pattern="framework/entity/lib/jdbc/[artifact]-[revision].[ext]" conf="mysql"/>
<echo> </echo>
Expand Down
26 changes: 0 additions & 26 deletions common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ under the License.
<pathelement location="@{build.jar}"/>
<pathelement location="@{build-test.jar}"/>
</classpath>
<sysproperty key="net.sourceforge.cobertura.datafile" file="${build.dir}/test-results/cobertura.dat" />
<sysproperty key="ofbiz.home" value="${ofbiz.home.dir}"/>
<formatter usefile="false" type="plain"/>
<batchtest>
Expand All @@ -129,31 +128,6 @@ under the License.
<run-junit/>
</target>

<patternset id="cobertura-src-dirs">
<include name="src"/>
</patternset>

<target name="tests-cobertura" depends="jar">
<mkdir dir="${build.dir}/cobertura-lib"/>
<taskdef resource="tasks.properties" classpathref="cobertura.class.path"/>
<delete file="${build.dir}/test-results/cobertura.dat"/>
<cobertura-instrument datafile="${build.dir}/test-results/cobertura.dat" todir="${build.dir}/cobertura-lib">
<fileset dir="${build.dir}/lib">
<include name="*.jar"/>
</fileset>
</cobertura-instrument>
<run-junit build.jar="${build.dir}/cobertura-lib/${name}.jar" build-test.jar="${build.dir}/cobertura-lib/${name}-test.jar"/>
<delete dir="${build.dir}/test-results/cobertura-report"/>
<mkdir dir="${build.dir}/test-results/cobertura-report"/>
<cobertura-report datafile="${build.dir}/test-results/cobertura.dat" destdir="${build.dir}/test-results/cobertura-report">
<dirset dir=".">
<patternset refid="cobertura-src-dirs"/>
</dirset>

<include name="**/*.java"/>
</cobertura-report>
</target>

<target name="all" depends="jar,docs"/>

<!-- ================================================================== -->
Expand Down
11 changes: 0 additions & 11 deletions framework/base/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,8 @@ under the License.
<file name="org/ofbiz/base/util/collections/test/GenericMapTest.java"/>
</filelist>

<patternset id="cobertura-src-dirs">
<include name="build/gen-src"/>
<include name="src"/>
</patternset>

<target name="init">
<condition property="exclude.cobertura" value="org/ofbiz/base/config/Cobertura*.java">
<not>
<available classname="net.sourceforge.cobertura.instrument.ClassInstrumenter" classpathref="cobertura.class.path"/>
</not>
</condition>
<patternset id="src.exc.set">
<exclude name="${exclude.cobertura}"/>
<exclude name="org/ofbiz/base/util/OfbizJsBsfEngine.java"/>
</patternset>
</target>
Expand Down
5 changes: 1 addition & 4 deletions framework/base/config/ofbiz-containers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ under the License.
<!-- load the ofbiz component container (always first) -->
<container name="component-container" loaders="main,rmi,pos,load-data" class="org.ofbiz.base.container.ComponentContainer"/>

<container name="component-container-test" loaders="test" class="org.ofbiz.base.container.ComponentContainer">
<property name="ofbiz.instrumenterClassName" value="org.ofbiz.base.config.CoberturaInstrumenter"/>
<property name="ofbiz.instrumenterFile" value="runtime/logs/cobertura-components.dat"/>
</container>
<container name="component-container-test" loaders="test" class="org.ofbiz.base.container.ComponentContainer"/>

<container name="component-container-limited" loaders="limited" class="org.ofbiz.base.container.ComponentContainer">
<property name="update-classpath" value="false"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,94 +0,0 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*******************************************************************************/
package org.ofbiz.base.config;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;

import net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler;
import net.sourceforge.cobertura.coveragedata.ProjectData;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.ofbiz.base.start.Instrumenter;

public final class CoberturaInstrumenter implements Instrumenter {
private static final Constructor<?> INSTRUMENTER_CONSTRUCTOR;
private static final Method IS_INSTRUMENTED_METHOD;
static {
try {
Class<?> clz = CoberturaInstrumenter.class.getClassLoader().loadClass("net.sourceforge.cobertura.instrument.ClassInstrumenter");
INSTRUMENTER_CONSTRUCTOR = clz.getConstructor(ProjectData.class, ClassVisitor.class, Collection.class, Collection.class);
INSTRUMENTER_CONSTRUCTOR.setAccessible(true);
IS_INSTRUMENTED_METHOD = clz.getDeclaredMethod("isInstrumented");
IS_INSTRUMENTED_METHOD.setAccessible(true);
} catch (Throwable t) {
throw (InternalError) new InternalError(t.getMessage()).initCause(t);
}
}

protected File dataFile;
protected ProjectData projectData;
protected boolean forInstrumenting;

public File getDefaultFile() throws IOException {
return CoverageDataFileHandler.getDefaultDataFile();
}

public void open(File dataFile, boolean forInstrumenting) throws IOException {
System.setProperty("net.sourceforge.cobertura.datafile", dataFile.toString());
this.forInstrumenting = forInstrumenting;
this.dataFile = dataFile;
if (forInstrumenting) {
if (dataFile.exists()) {
projectData = CoverageDataFileHandler.loadCoverageData(dataFile);
} else {
projectData = new ProjectData();
}
}
}

public void close() throws IOException {
if (forInstrumenting) {
CoverageDataFileHandler.saveCoverageData(projectData, dataFile);
}
}

public byte[] instrumentClass(byte[] bytes) throws IOException {
if (forInstrumenting) {
ClassReader cr = new ClassReader(bytes);
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS/* | ClassWriter.COMPUTE_FRAMES*/);
try {
ClassVisitor ci = (ClassVisitor) INSTRUMENTER_CONSTRUCTOR.newInstance(projectData, cw, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
cr.accept(ci, 0);
if (((Boolean) IS_INSTRUMENTED_METHOD.invoke(ci)).booleanValue()) {
return cw.toByteArray();
}
} catch (Throwable t) {
throw (IOException) new IOException(t.getMessage()).initCause(t);
}
}
return bytes;
}
}
Loading

0 comments on commit ca819dd

Please sign in to comment.