package does not exist errors while building with bb ant tools - java

Im trying to automate our build process using bb ant tools and im running into a few errors
There are 3 different errors where 2 of them are related
[javac] D:\dev\java\workspaces\bb workspace\blackberry\Adaffix\src\com\adaffix\blackberry\AdaffixApplication.java:55: cannot find symbol [javac] symbol: class PhoneListener [javac] public class AdaffixApplication extends UiApplication implements PhoneListener, GlobalEventListener {
[javac] D:\dev\java\workspaces\bb workspace\blackberry\Adaffix\src\com\adaffix\blackberry\AdaffixApplication.java:29: package net.rim.blackberry.api.invoke does not exist [javac] import net.rim.blackberry.api.invoke.Invoke;
[javac] D:\dev\java\workspaces\bb workspace\blackberry\Adaffix\src\com\adaffix\blackberry\main\block\AddBlock.java:167: warning: unmappable character for encoding UTF-8 [javac] //tilf?j til db
and here is my build.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="appname" default="build" basedir=".">
<!-- BLACKBERRY ANT TOOLS -->
<property name="bb-ant-tools.home" location="D:/dev/bb-ant-tools-1.2.13-bin" />
<taskdef resource="bb-ant-defs.xml" classpath="${bb-ant-tools.home}/bb-ant-tools.jar" />
<property name="jdehome" value="D:/dev/eclipse/blackberry/plugins/net.rim.ejde.componentpack6.0.0_6.0.0.43/components" />
<property name="jdkhome" value="C:/Program Files (x86)/Java/jdk1.6.0_34" />
<!-- CONFIG STUFF -->
<property name="cod.name" value="appname" />
<property name="app.name" value="appname" />
<property name="app.version" value="2.7.5" />
<property name="app.description" value="" />
<property name="app.vendor" value="appname GmbH" />
<!-- FOLDERS -->
<property name="build.dir" location="D:/dev/java/workspaces/bb workspace/blackberry/build" />
<property name="bbminterface.dir" location="D:/dev/java/workspaces/bb workspace/blackberry/BBMInterface" />
<property name="bbmimpl.dir" location="D:/dev/java/workspaces/bb workspace/blackberry/BBMImplementation" />
<property name="main.dir" location="D:/dev/java/workspaces/bb workspace/blackberry/appname" />
<target name="build" description="Builds Project">
<!--<mkdir dir="${build.dir}" /> -->
<javac target="1.4" source="1.4" destdir="${build.dir}" encoding="utf-8">
<src path="${bbminterface.dir}/src"/>
<src path="${bbmimpl.dir}/src"/>
<src path="${main.dir}/src"/>
</javac>
<rapc output="BBMInterface" destdir="${build.dir}" jdehome="${jdehome}" jdkhome="${jdkhome}" verbose="false" quiet="true" nowarn="true">
<src>
<fileset dir="${bbminterface.dir}/src"/>
</src>
<jdp type="library" title="appname BBM Interface" vendor="${app.vendor}" version="1.0.0">
<entry title="appname BBM Interface" description=""/>
</jdp>
</rapc>
<rapc output="BBMImplementation" destdir="${build.dir}" jdehome="${jdehome}" jdkhome="${jdkhome}" verbose="false" quiet="true" nowarn="true">
<src>
<fileset dir="${bbmimpl.dir}/src"/>
</src>
<import location="${bbmimpl.dir}/external jars/bbm sdk/net_rim_bb_qm_platform.jar" />
<import location="${build.dir}/BBMInterface.jar" />
<jdp type="library" title="appname BBM Implementation" vendor="${app.vendor}" version="1.0.0" runonstartup="true" startuptier="6">
<entry title="appname BBM Implementation" description="" runonstartup="true" startuptier="6"/>
</jdp>
</rapc>
<javac srcdir="${main.dir}" encoding="UTF-8" />
<rapc output="${cod.name}" destdir="${build.dir}" jdehome="${jdehome}" jdkhome="${jdkhome}" verbose="false">
<src>
<fileset dir="${main.dir}/src" />
</src>
<src>
<fileset dir="${main.dir}/res" />
</src>
<src>
<fileset file="${main.dir}/external jars/bb payment sdk/paymentapi.jar" />
<fileset file="${main.dir}/external jars/bb advertising sdk/net_rim_bbapi_adv_app.jar" />
</src>
<import location="${main.dir}/external jars/bb payment sdk/paymentapi.jar" />
<import location="${main.dir}/external jars/bb advertising sdk/net_rim_bbapi_adv_app.jar" />
<import location="${build.dir}/BBMInterface.jar"/>
<jdp type="cldc" title="${app.name}" vendor="${app.vendor}" icon="${main.dir}/res/image/icon.png" version="${app.version}" description="${app.description}" startuptier="7" ribbonposition="0">
<entry title="${app.name}" icon="${main.dir}/res/image/icon.png" description="${app.description}" runonstartup="true" arguments="boot" systemmodule="true" startuptier="7" ribbonposition="0" />
<!--<entry title="${app.name}" icon="../res/icon.png" description="#{description}" arguments="daemon" runonstartup="true" systemmodule="true" startuptier="7" ribbonposition="0" /> -->
</jdp>
</rapc>
<sigtool codfile="${build.dir}/BBMInterface.cod" password="password"/>
<sigtool codfile="${build.dir}/BBMImplementation.cod" password="password"/>
<sigtool codfile="${build.dir}/${cod.name}.cod" password="password" />
</target>
<target name="sign" description="Sign the cod files">
</target>
<!--<target name="clean">
<delete dir="${dest.dir}" />
</target> -->
</project>
can anyone point me in the right direction? im kind of lost here
i thought that all the RIM api's would get included by bb ant tools automatically

Are you building on Linux or Windows? Rapc compiles java source to .class files with the Java SDK "javac" before compiling the class files into .cod files. Unfortunately, rapc does not provide any way to pass the "-encoding" option to javac, so you are stuck with the platform default encoding. This is cp-1252 on Windows, MacRoman on OSX, and UTF-8 on Linux. Since it is trying to interpret your source as UTF-8, I'll guess you're using linux.
There are three options for fixing this:
You can go back to explicitly compiling the java source with the javac ant task. Your previous attempt wasn't working because you were still passing source code to rapc. Rapc can also start with class files, so you would do the javac step yourself, then pass the output directory to rapc for processing.
If you don't want to sort out the javac command yourself, you can also override the default system encoding, with a patch to bb-ant-tools.
If you only ever build your BlackBerry application on Linux, you can just switch your source file encoding to UTF-8 and be done with this. This won't work well if any developers are using Windows though. Windows is a common choice as it is the only place the simulators work. By switching to UTF-8 encoding, the Windows developers will face the same problem you are facing now - rapc will be compiling with the system default of cp-1252, but the source files will be in UTF-8.

The problem isn't in bb-ant-tools.
Why do you need javac part if your rapc could build project from sources? You even don't use result of javac after. My recommendation to remove it and it will fix your build.

happened to me. was because i hadn't copied selenium-server-standalone-3.4.0.jar to my C:\jars dir (ws.jars)

Related

sonar's code coverage using ANt (build.xml)

I am trying to use my junit test for sonar's code coverage. I am using Ant. I am trying to update build.xml like this:
<!-- ========= Define SonarQube Scanner for Ant Target ========= -->
<target name="sonar" depends="compile">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<!-- Update the following line, or put the "sonar-ant-task-*.jar" file in your "$HOME/.ant/lib" folder -->
<classpath path="/lib/sonar-ant-task-2.0.jar" />
</taskdef>
<!-- Execute SonarQube Scanner for Ant Analysis -->
<sonar:sonar />
</target>
But it is showing "resource="org/sonar/ant/antlib.xml" not found. I have sonar-ant-task-2.0.jar in my lib folder. and I am using intellij.
This . are the properties i added in build.xml
<property name="sonar.projectKey" value="org.codehaus.sonar:example-java-ant" />
<property name="sonar.projectName" value="SIML project" />
<property name="sonar.projectVersion" value="1.0" />
<property name="sonar.test" value="test" />
Please help :) :)
And let me know if you need any other information to make question clear. :)

Jenkins Ant build failed "src does not exist!"

When I run my code in the console, it runs fine. It also runs fine on eclipse. But when I try to build on Jenkins, it is asking for a src folder:
"C:\Program Files (x86)\Jenkins\Work space\job1\src" does not exist!
build.xml
<project name="Sample Ant build" basedir=".">
<!-- ========== Initialize Properties =================================== -->
<!-- set global properties for build -->
<property name="basedir" value="." />
<property name="lib" value="${basedir}/lib" />
<property name="src" value="${basedir}/src" />
<property name="bin" value="${basedir}/bin" />
<property name="report-dir" value="${basedir}/Test-Report" />
<property name="testng-report-dir" value="${report-dir}/TestNGreport" />
<!-- ====== Set the classpath ==== -->
<path id="classpath">
<pathelement location="${bin}" />
<fileset dir="C:\WebDriver\Selenium">
<include name="*.jar" />
</fileset>
</path>
<!-- Delete directories -->
<target name="delete-dir">
<delete dir="${bin}" />
<delete dir="${report-dir}" />
</target>
<!-- Creating directories -->
<target name="create" depends="delete-dir">
<mkdir dir="${bin}" />
<mkdir dir="${report-dir}" />
</target>
<!-- Compile the java code from ${src} into ${bin} -->
<target name="compile" depends="create">
<javac srcdir="${src}" classpathref="classpath" includeAntRuntime="No" destdir="${bin}" />
<echo> /* Compiled Directory Classes */ </echo>
</target>
<!-- Runs the file and generates Reportng report for TestNG-->
<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="classpath" />
<target name="testng-execution" depends="compile">
<mkdir dir="${testng-report-dir}" />
<testng outputdir="${testng-report-dir}" classpathref="classpath" useDefaultListeners="true">
<xmlfileset dir="${basedir}" includes="testng.xml" />
</testng>
</target>
Eclipse uses a workspace, Jenkins uses a workspace (and in our case, TFS also uses a workspace). They are not the same thing. (Your query is missing some details to answer authoritatively, some some assumptions were made)
Your build.xml script sets BASEDIR to ".", or the working directory. For a Jenkins job, that is as below - See Administering Jenkins:
JENKINS_HOME
+- workspace (working directory for the version control system)
+- [JOBNAME] (sub directory for each job)
In your case, JENKINS_HOME\workspace\[JOBNAME] is C:\Program Files (x86)\Jenkins\Work space\job1.
My money is that is not where your Eclipse workspace is mapped to.
I would make the following recommendations:
Develop your code and test it in Your Eclipse IDE. When satisfied, commit to your version control system (VCS).
Setup Jenkins to pull code from your VCS into the local workspace of your job and build there. As it's separate to your working copy it helps isolate changes and ensures you have committed everything to source control so your builds come from a know, reproducible source.
Set JEKNINS_HOME to a location outside of C:\Program Files ...; it's bad practice to place data (like source files and a build) in a location from installation binaries. Lots of goods reasons to do so, including security, easier space management, etc.
Choose an appropriate location and set the directory configurations for the Master (Jenkins | Manage Jenkins | Configure System; the first 3 values)
IF using distributed builds (master/node), within your node configuration (Jenkins | Manage Jenkins | Manage Nodes | Configure => Remote Root directory ) to an appropriate location

I'm trying to utilizing SASS in an ant file while removing ruby dependencies

I am currently using a ruby gem SASS in order to convert my *.scss files to *.css files on a large project. Here is a mockup of the code I am using:
<?xml version="1.0"?>
<!-- scss to CSS -->
<project name="StackOverflowScssCss" default="sass-compile-to-css" basedir=".">
<property file="build.properties" />
<target name="sass-compile-to-css">
<echo message="Compiling scss files to css..." />
<!-- create the css destination dir if it doesn't already exist -->
<property name="css-dest" location="${css.dir}" />
<echo message="Creating directory at ${css.dir} [if it doesn't yet exist]" />
<mkdir dir="${css-dest}" />
<!-- create subdirs if necessary -->
<echo message="Creating css directories (and temporary .css files) for .scss to be compiled..." />
<touch mkdirs="true">
<fileset dir="${sass.dir}" includes="**/*.scss" excludes="**/_*" />
<mapper type="glob" from="*.scss" to="${css.dir}/*.css" />
</touch>
<echo message="Running sass executable against sass files and compiling to CSS directory [${css-dest}] " />
<!-- run sass executable -->
<apply executable="sass" dest="${css-dest}" verbose="true" force="true" failonerror="true">
<arg value="--unix-newlines" />
<!-- Disable creation of map file. THIS SHOULD BE A FLAG -->
<arg value="--sourcemap=none" />
<srcfile />
<targetfile />
<fileset dir="${sass.dir}" includes="**/*.scss" excludes="**/_*" />
<mapper type="glob" from="*.scss" to="*.css" />
</apply>
<echo message="Done compiling scss files!" />
</target>
</project>
Ultimately I want to remove the ruby dependency so I have been looking at this libsass maven plugin. I know that there are many options for libsass but I am trying to stick strictly to Java. Does anyone have any experience with doing this? I don't want to run Node.js, Sass.js ot anything, and I have racked my brain all day on how to do this. Any help is much appreciated!
There is a Java wrapper that can be used with Maven.
If you really want to stick with Java you could either
Use that wrapper and run the mvn task from inside your ant script (see here)
Adapt that wrapper and build your own Ant Task out of it
I ended up using a JRuby dependency in order to run on the JVM. My code is as follows:
<!-- Jruby Dependent SCSS to CSS conversion -->
<path id="JRuby">
<fileset file="packages/jruby-complete-1.7.20.1.jar"/> <!-- Location of JRuby jar file -->
</path>
<target name="compileSass" depends="cleanSass">
<echo message="Compiling scss files..." />
<!-- JRuby Script to convert files into new directory -->
<property name="filesIn" value="${dir.scss}/**/[^_]*.scss" />
<property name="projectDirectory" value="${user.dir}"/>
<script language="ruby" classpathref="JRuby">
<![CDATA[
require ($project.getProperty('projectDirectory')) + '/packages/sass-3.4.14/lib/sass'
require ($project.getProperty('projectDirectory')) + '/packages/sass-3.4.14/lib/sass/exec'
files = Dir.glob($project.getProperty('filesIn'))
files.each do
| file |
newOutDir = File.dirname(file).sub! 'scss', 'css'
FileUtils::mkdir_p newOutDir
puts "[sass compiler] From:" + file
puts "[sass compiler] To:" + newOutDir + "/" + File.basename(file, ".*") + ".css"
opts = Sass::Exec::SassScss.new(["--load-path", File.dirname(file), file, File.join(newOutDir, File.basename(file, ".*") + ".css")], 'scss')
opts.parse
end
]]>
</script>
<echo message="Done compiling scss files!" />
</target>
<target name="cleanSass">
<echo message="removing .css files..." />
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${dir.css}" includes="**/*.css" />
</delete>
<echo message="removing .css.map files..." />
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${dir.css}" includes="**/*.css.map" />
</delete>
</target>

J2ME Polish - Unable to execute J2ME Polish task: java.lang.IllegalArgumentException: The property [dir.dist] is not defined in input [${dir.dist}]

I am trying to get a J2ME Polish sample project up and running, but am struggling.
I am using Netbeans 8.0.2 with the J2ME Polish plugin.
When I try to create a J2ME Polish project (File > New Project > Java ME > J2ME Polish Project), the New Project wizard works fine until I get to the last step, at which point clicking the Finish button does not do anything. I then have to close the wizard and open the project manually (which appears to have been created - although maybe not fully?).
Next, I fix the resource complaint by referencing enough-j2mepolish-client.jar after I have relocated it to root of my project.
I then try to clean and build the project, but I get this error in my Output window:
ant -f M:\\Netbeans\\J2ME-Polish-Project rebuild
clean:
Deleting directory M:\Netbeans\J2ME-Polish-Project\build
pre-init:
pre-load-properties:
exists.config.active:
exists.netbeans.user:
exists.user.properties.file:
load-properties:
exists.platform.active:
exists.platform.configuration:
exists.platform.profile:
basic-init:
cldc-pre-init:
cldc-init:
cdc-init:
semc-pre-init:
semc-init:
savaje-pre-init:
savaje-init:
sjmc-pre-init:
sjmc-init:
ojec-pre-init:
ojec-init:
cdc-hi-pre-init:
cdc-hi-init:
nokiaS80-pre-init:
nokiaS80-init:
post-init:
init:
j2mepolish-init:
j2mepolish:
J2ME Polish 2.4 (2013-08-27) (GPL License)
Loading device database...
Processing [7] devices...
building application for [Generic/jtwi] (1/7):
using locale [de_DE]...
java.lang.IllegalArgumentException: The property [dir.dist] is not defined in input [${dir.dist}]
at de.enough.polish.Environment.getProperty(Environment.java:537)
at de.enough.polish.Environment.writeProperties(Environment.java:452)
at de.enough.polish.ant.build.BuildSetting.getDestDir(BuildSetting.java:621)
at de.enough.polish.ant.PolishTask.initialize(PolishTask.java:1613)
at de.enough.polish.ant.PolishTask.execute(PolishTask.java:600)
at de.enough.polish.ant.PolishTask.execute(PolishTask.java:436)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
M:\Netbeans\J2ME-Polish-Project\build.xml:82: Unable to execute J2ME Polish task:
java.lang.IllegalArgumentException: The property [dir.dist] is not defined in input [${dir.dist}]
at de.enough.polish.Environment.getProperty(Environment.java:537)
at de.enough.polish.Environment.writeProperties(Environment.java:452)
at de.enough.polish.ant.build.BuildSetting.getDestDir(BuildSetting.java:621)
at de.enough.polish.ant.PolishTask.initialize(PolishTask.java:1613)
at de.enough.polish.ant.PolishTask.execute(PolishTask.java:600)
at de.enough.polish.ant.PolishTask.execute(PolishTask.java:436)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
BUILD FAILED (total time: 1 second)
As well as J2ME Polish, I'm also brand new to Ant, so maybe this could be a simple one to solve (although I haven't managed after 1 hour...).
For completeness, here is my build.xml file:
<!-- When you are using NetBeans 5, just rename this file -->
<!-- to build.xml. You can then use the normal menu items -->
<!-- run, debug, build and so forth from within NetBeans. -->
<!-- This file controls the build process. -->
<!-- The most important target is the "j2mepolish", -->
<!-- which controls for what devices the application should -->
<!-- be created and so on. -->
<!-- -->
<!-- Call the "emulator" target to skip the obfuscation -->
<!-- and to build the example for only one handsets. -->
<!-- The default target builds and obfuscates the example. -->
<!-- -->
<!-- The full documentation can be found at -->
<!-- http://www.j2mepolish.org -->
<!-- -->
<!-- Have fun! -->
<project
name="J2ME-Polish-Project"
default="j2mepolish">
<!-- extend the default NetBeans build script: -->
<import file="nbproject/build-impl.xml"/>
<!-- The polish.home property needs to point to the directory -->
<!-- containing the J2ME Polish installation. -->
<property name="polish.home" location="P:\Program Files\J2ME-Polish" />
<!-- import global properties -->
<property file="${polish.home}/global.properties" />
<!-- Definition of the J2ME Polish task: -->
<taskdef name="j2mepolish"
classname="de.enough.polish.ant.PolishTask"
classpath="${polish.home}/lib/enough-j2mepolish-build.jar"
/>
<!-- build targets, each target can be called via "ant [name]",
e.g. "ant clean", "ant test j2mepolish" or just "ant" for calling the default-target -->
<target name="setdeploy"
description="Call this target first to set the OTA download-URL, e.g. ant setdeploy j2mepolish"
>
<property name="deploy-url" value="http://www.company.com/download/" />
</target>
<target name="enableDebug"
description="Call this target first to skip the obfuscation step, call the emulator and start the debugger, e.g. ant enableDebug j2mepolish"
>
<property name="debug" value="true" />
</target>
<target name="test"
description="Call this target first to skip the obfuscation step and call the emulator, e.g. ant test j2mepolish"
>
<property name="test" value="true" />
<property name="dir.work" value="build/test" />
</target>
<target name="j2mepolish-init"
depends="init"
>
<property name="test" value="false" />
<property name="dir.work" value="build/real" />
<property name="deploy-url" value="" />
</target>
<!-- In this target the J2ME Polish task is used. -->
<!-- It has 3 sections: -->
<!-- 1. The info-section defines some general information -->
<!-- 2. The deviceRequirements-section chooses the devices -->
<!-- for which the application is optimized. -->
<!-- 3. The build-section controls the actual build -->
<!-- process. -->
<target name="j2mepolish"
depends="j2mepolish-init"
description="This is the controller for the J2ME build process."
>
<j2mepolish>
<!-- general settings, these settings basically form the JAD-attributes. -->
<!-- Have a look at the <jad>-section for setting specialised attributes.
You can also define localized attributes in the resources/messages.txt files -->
<info
name="J2ME Polish"
version="1.3.4"
description="A simple project that uses localization."
vendorName="Enough Software"
infoUrl="http://www.j2mepolish.org"
icon="dot.png"
jarName="${polish.vendor}-${polish.name}-${polish.locale}-menu.jar"
jarUrl="${deploy-url}${polish.jarName}"
copyright="Copyright 2005 - 2011 Enough Software. All rights reserved."
deleteConfirm="Do you really want to kill me?"
/>
<!-- selection of supported devices -->
<deviceRequirements if="config.active:defined and (test or enableCompilerMode)" >
<requirement name="Identifier" value="${config.active}" />
</deviceRequirements>
<deviceRequirements if="device:defined and (test or enableCompilerMode)" unless="config.active:defined">
<requirement name="Identifier" value="${device}" />
</deviceRequirements>
<deviceRequirements unless="test or enableCompilerMode">
<requirement name="Identifier" value="${devices}" />
</deviceRequirements>
<!-- build settings -->
<!--
-->
<build
usePolishGui="true"
workDir="${dir.work}"
destDir="${dir.dist}"
compilerMode="${enableCompilerMode}"
compilerDestDir="build/classes"
compilerModePreverify="true"
>
<!-- midlets definition, NetBeans defines all MIDlets in the Ant property manifest.midlets: -->
<midlets definition="${manifest.midlets}" if="manifest.midlets:defined" />
<midlets unless="manifest.midlets:defined">
<midlet class="de.enough.polish.example.MenuMidlet" name="Example" />
</midlets>
<!-- project-wide variables - used for preprocessing. -->
<!-- You can set localized variables in the resources/messages.txt files as well. -->
<variables includeAntProperties="true" >
<!-- use the advanced menubar mode that offers near-native command handling and positioning, on BB and Android use native commands: -->
<variable
name="polish.FullScreen"
value="menu"
unless="polish.blackberry || polish.android"
/>
<variable name="polish.MenuBar.useExtendedMenuBar" value="true" />
<!-- example variables:
In your Java-code you can use the following snipet to use this variable:
//#= private static final String UPDATE_URL = "${ update-url }";
You can change the title of the sample application with the "title"-var.
-->
<variable name="update-url" value="http://www.enough.de/update" />
<variable name="title" value="J2ME Polish" />
</variables>
<!-- Here you can set the dir attribute to "resources2" for an alternative design. -->
<resources
dir="resources/base"
defaultexcludes="yes"
excludes="readme.txt"
>
<root dir="resources/customizations/${customization}" if="${customization}.enabled" />
<!-- add the localization element for created localized
versions of your application: -->
<localization locales="de_DE, en_US" unless="test" />
<localization locales="en_US" if="test" />
</resources>
<!-- obfuscator settings: do not obfuscate when the test-property is true -->
<obfuscator name="ProGuard" unless="test or polish.blackberry" >
<!--
You can set additional parameters here, e.g.:
<parameter name="optimize" value="false" />
-->
</obfuscator>
<!-- debug settings: only include debug setting when the test-property is true -->
<debug if="test or log" verbose="true" level="error">
<filter pattern="de.enough.polish.example.*" level="debug" />
<filter pattern="de.enough.polish.ui.*" level="warn" />
<!-- activate display handler to see log entries in real time:
<handler name="display" />
-->
</debug>
<!-- user defined JAD attributes can also be used: -->
<jad>
<attribute name="Nokia-MIDlet-Category" value="Game" if="polish.group.Series40" />
</jad>
<!--
This is an example for signing MIDlets with J2ME Polish.
You can set the password on the commandline by calling "ant -Dpassword=secret",
or by setting the Ant property above.
Signing is done only for MIDP/2.0 devices.
-->
<!--
<sign
key="SignMIDlet"
keystore="midlets.ks"
password="${password}"
unless="test"
/>
-->
</build>
<!-- execution of emulator(s) -->
<emulator
wait="true"
trace="class"
securityDomain="trusted"
enableProfiler="true"
enableMemoryMonitor="true"
enableNetworkMonitor="true"
if="test and not debug"
>
<!--
<parameter name="-Xjam" value="transient=http://localhost:8080/${polish.jadName}" />
-->
</emulator>
<emulator
wait="true"
trace="class"
securityDomain="trusted"
enableProfiler="false"
enableMemoryMonitor="false"
enableNetworkMonitor="false"
if="debug"
>
<!-- Attach the emulator to the NetBeans debugger: -->
<debugger name="antcall" target="connect-debugger" port="6001" />
</emulator>
</j2mepolish>
</target>
<target
name="emulator"
depends="test,j2mepolish"
description="invokes the emulator"
>
</target>
<target name="clean"
description="allows a clean build. You should call [ant clean] whenever you made changes to devices.xml, vendors.xml or groups.xml">
<delete dir="build" />
<delete dir="dist" includes="**/*" />
</target>
<target
name="cleanbuild"
description="allows a clean build. You should call [ant cleanbuild] whenever you made changes to devices.xml, vendors.xml or groups.xml"
depends="clean, j2mepolish"
/>
<target name="debug" description="debugs the project" depends="enableDebug, test, j2mepolish" />
<target name="deploy"
description="Deploys the applications. Currently empty."
depends="j2mepolish"
/>
<target name="enableBarbie">
<property name="customization" value="Barbie" />
<property name="Barbie.enabled" value="true" />
</target>
<target name="barbie"
description="customizes this project with the settings found in resources/customizations/Barbie"
depends="enableBarbie, j2mepolish"
/>
<target name="enableFrogger">
<property name="customization" value="Frogger" />
<property name="Frogger.enabled" value="true" />
</target>
<target name="frogger"
description="customizes this project with the settings found in resources/customizations/Barbie"
depends="enableFrogger, j2mepolish"
/>
<target name="enableAnimations">
<property name="customization" value="Animations" />
<property name="Animations.enabled" value="true" />
<property name="polish.MenuBar.useExtendedMenubar" value="true" />
</target>
<target name="animations"
description="customizes this project with the settings found in resources/customizations/Animations"
depends="enableAnimations, j2mepolish"
/>
<target
name="build-all"
description="Builds your application in all customizations."
>
<subant target="j2mepolish" buildpath="." genericantfile="build.xml" inheritall="false" ></subant>
<subant target="frogger" buildpath="." genericantfile="build.xml" inheritall="false" ></subant>
<subant target="barbie" buildpath="." genericantfile="build.xml" inheritall="false" ></subant>
<subant target="animations" buildpath="." genericantfile="build.xml" inheritall="false" ></subant>
</target>
<!-- NetBeans specific build targets: -->
<target name="run"
depends="test, j2mepolish"
>
</target>
<target name="rebuild"
depends="clean, j2mepolish"
>
</target>
<target name="rebuild-all"
depends="clean, j2mepolish"
>
</target>
<target name="jar"
depends="j2mepolish"
>
</target>
<target name="jar-all"
depends="j2mepolish"
>
</target>
<target name="clean-all"
depends="clean"
>
</target>
<target name="deploy-all"
depends="deploy"
>
</target>
<target name="enable-compiler-mode">
<property name="enableCompilerMode" value="true" />
</target>
<target name="compile-single"
depends="enable-compiler-mode, j2mepolish"
>
</target>
<target name="connect-debugger">
<property name="jpda.port" value="${polish.debug.port}" />
<antcall target="nbdebug"/>
</target>
</project>
Any help much appreciated.
Update: (17-Feb-2015)
I have added <property name="dir.dist" value="dist" /> (right after the existing <property name="dir.work" value="build/real" /> line), but now I get this error when trying to clean/build the project:
ant -f M:\\Netbeans\\J2ME-Polish-Project rebuild
clean:
Deleting directory M:\Netbeans\J2ME-Polish-Project\build
pre-init:
pre-load-properties:
exists.config.active:
exists.netbeans.user:
exists.user.properties.file:
load-properties:
exists.platform.active:
exists.platform.configuration:
exists.platform.profile:
basic-init:
cldc-pre-init:
cldc-init:
cdc-init:
semc-pre-init:
semc-init:
savaje-pre-init:
savaje-init:
sjmc-pre-init:
sjmc-init:
ojec-pre-init:
ojec-init:
cdc-hi-pre-init:
cdc-hi-init:
nokiaS80-pre-init:
nokiaS80-init:
post-init:
init:
j2mepolish-init:
j2mepolish:
J2ME Polish 2.4 (2013-08-27) (GPL License)
Loading device database...
Processing [7] devices...
building application for [Generic/jtwi] (1/7):
using locale [de_DE]...
M:\Netbeans\J2ME-Polish-Project\build.xml:83: build.xml line 0: found no operator before symbol [.enabled] in term [${customization}.enabled] (both symbol and term might be simplified).
BUILD FAILED (total time: 1 second)
I never got to the bottom of this specific error message, but I did manage to get another J2ME Polish demo project up and running in the end - from which point I could adapt the project as per my requirements.
Basically, I had no joy with Netbeans 8.0, so I used Netbeans 7.2.1. And the demo project that worked for me (which you select in the last step of the J2ME Polish New Project wizard) was the datefield project.
I also found it's important to select a specific device to get the project to compile - I just selected the Generic/midp2 device (found under the Virtual section in the wizard) and make sure it is selected as the current configuration when you build the project.
I expect there will be many other variations that also work, but after a lot of farting around, this is the combination that eventually worked for me - so hopefully this will be a good starting point for someone else.

Why is Sonar design view not showing any dependencies for my project?

I've successfully set up Sonar against a large Java project that is built using Ant. I've finally hooked up the JUnit test results and the Cobertura code coverage report.
I now see all the packages in the design view but there are no values for dependencies between any of the packages or classes (see example below).
Does anyone have any idea what I have missed here?
UPDATE
Looking at the output of the Sonar Ant task I also notice that the package design task is completing very quickly for what is a fairly large and complicated project. From the Ant output:
[sonar:sonar] [INFO] Package design analysis...
[sonar:sonar] [INFO] Package design analysis done: 66 ms
The Ant task is as follows:
<target name="sonar" depends="collate-xml-reports">
<sonar:sonar workDir="src/build/sonarTemp" key="myProjectKeyWhichHasBeenChangedToHideMyClient" version="1.0" xmlns:sonar="antlib:org.sonar.ant">
<!-- source directories (required) -->
<sources>
<path location="src/common/src" />
<path location="src/commonWidgets/src" />
<path location="src/compositionWidget/src" />
<path location="src/nativeLib/src" />
<path location="src/services/src" />
</sources>
<!-- list of properties (optional) -->
<property key="sonar.projectName" value="RPS Nightly" />
<property key="sonar.dynamicAnalysis" value="reuseReports" />
<property key="sonar.surefire.reportsPath" value="src/reports/junit" />
<property key="sonar.cobertura.reportPath" value="src/reports/cobertura/coverage.xml" />
<!-- test source directories (optional) -->
<tests>
<path location="src/common/test" />
<path location="src/commonWidgets/test" />
<path location="src/compositionWidget/test" />
<path location="src/services/test" />
</tests>
<!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
<binaries>
<path location="src/common/build" />
<path location="src/commonWidgets/build" />
<path location="src/compositionWidget/build" />
<path location="src/services/build" />
</binaries>
<!-- path to libraries (optional). These libraries are for example used by the Java Findbugs plugin -->
<libraries>
<path location="src/common/lib/**/" />
<path location="src/commonWidgets/lib/**/" />
<path location="src/compositionWidget/lib/**/" />
<path location="src/services/lib/" />
</libraries>
</sonar:sonar>
</target>
Being a Java n00b it turns out that this was a misunderstanding on my part. The binaries directory locations need to point to the root folder of the compiled Java bytecode but I was pointing it to the jar file location. In this case the bytecode is written to the build/classes folder so I needed to modify my ant target (shown in the question) from:
<binaries>
<path location="src/common/build" />
<path location="src/commonWidgets/build" />
<path location="src/compositionWidget/build" />
<path location="src/services/build" />
</binaries>
To:
<binaries>
<path location="src/common/build/classes" />
<path location="src/commonWidgets/build/classes" />
<path location="src/compositionWidget/build/classes" />
<path location="src/services/build/classes" />
</binaries>
This fixed the problem and the design view is now correctly populated.

Categories

Resources