My Gitlab CI for ANT project is giving Build fail error and also "Target "HelloWorld" does not exist in the project "null"."
I am using "ant clean build" command in script to build the project.
My build.xml :
<project>
<target name="clean">
<delete dir="bin"/>
</target>
<target name="build">
<mkdir dir="bin"/>
<javac srcdir="src" destdir="bin"/>
</target>
<target name="jar">
<mkdir dir="bin/jar"/>
<jar destfile="bin/jar/HelloWorld.jar" basedir="bin">
<manifest>
<attribute name="Main-Class" value="Main"/>
</manifest>
</jar>
</target>
<target name="run">
<java jar="bin/jar/HelloWorld.jar" fork="true"/>
</target>
My HelloWorld.Java
package javaapplication1;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
My folder structure is:
Can someone let me know how to make this build successful ?
I have a dynamic web project which I deploy in EAR format on JBoss 5. Using ant I compile and deploy the ear file on application server. If I deploy EJB and war (client) independently then everything work but when i try to package in ear session bean does not bound. My EJB code and client(Web) are in same project I do not have Independent EJB modules in project. I tried adding jar out of business interface in WEB-INF lib and even in lib directory of ear file but nothing worked. I want to know If EJB jar is not in the class path and how to set order of modules in ear file?
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" id="Application_ID" version="5">
<display-name>X3</display-name>
<module>
<web>
<web-uri>x3.war</web-uri>
<context-root>x3</context-root>
</web>
</module>
<module>
<ejb>x3.jar</ejb>
</module>
</application>
build.xml
<?xml version="1.0"?>
<!DOCTYPE xml>
<project name="x3" default="all" basedir=".">
<property name="compiledWebClasses" value="${basedir}/build/classes" />
<property name="dist" value="${basedir}/dist" />
<property name="descriptors" value="${basedir}/dd" />
<property name="build" value="${basedir}/build" />
<property name="JBOSS_CLIENT_LIB" value="C:\jboss5dummy\jboss-5.0.1.GA\client" />
<property name="JBOSS_LIB" value="C:\jboss5dummy\jboss-5.0.1.GA\lib" />
<property name="JBOSS_COMMON_LIB" value="C:\jboss5dummy\jboss-5.0.1.GA\common\lib" />
<path id="compile.classpath">
<fileset dir="${JBOSS_CLIENT_LIB}">
<include name="*.jar"/>
</fileset>
<fileset dir="${JBOSS_LIB}">
<include name="*.jar"/>
</fileset>
<fileset dir="${JBOSS_COMMON_LIB}">
<include name="*.jar"/>
</fileset>
</path>
<target name="clean">
<delete dir="${basedir}/build" />
<delete dir="${basedir}/dist" />
</target>
<target name="createFolders">
<mkdir dir="${basedir}/build/classes" />
<mkdir dir="${basedir}/dist" />
</target>
<target name="compile">
<javac srcdir="src" destdir="build/classes" debug="true">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="jar">
<jar jarfile="${build}/x3.jar">
<fileset dir="${compiledWebClasses}">
<include name="**/ejb/**"/>
</fileset>
<metainf dir="${descriptors}">
<include name="persistence.xml"/>
</metainf>
</jar>
</target>
<fileset dir="${compiledWebClasses}" id="warClasses.fileset">
<include name="**/controller/**" />
</fileset>
<target name="war">
<war destfile="${build}/x3.war" webxml="${basedir}/WebContent/WEB-INF/web.xml">
<fileset dir="${basedir}/WebContent"/>
<classes refid="warClasses.fileset"/>
</war>
</target>
<target name="ear">
<jar destfile="${dist}/x3.ear">
<metainf dir="${descriptors}">
<include name="application.xml"/>
<include name="jboss-app.xml"/>
</metainf>
<fileset file="${build}/x3.war"/>
<fileset file="${build}/x3.jar"/>
</jar>
</target>
<target name="all" depends="clean, createFolders, compile, jar, war, ear">
<echo message="done" />
</target>
</project>
jboss-app.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<jboss-app>
<loader-repository>dev.lmd.com:loader=x3.ear</loader-repository>
</jboss-app>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="StudentMgtPU"
transaction-type="JTA">
<jta-data-source>java:/StudentMgtDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
</persistence>
Business Interface
package com.lmd.dev.ejb.session;
import javax.ejb.Local;
import com.lmd.dev.ejb.domain.Student;
#Local
public interface ManageStudentSessionBeanLocal {
public boolean addStudent(Student Student);
}
Business Logic
package com.lmd.dev.ejb.session;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.lmd.dev.ejb.domain.Student;
/**
* Session Bean implementation class ManageStudentSessionBean
*
* #author Sameera Jayasekara
*/
#Stateless
public class ManageStudentSessionBean implements ManageStudentSessionBeanLocal {
#PersistenceContext
private EntityManager entityManager;
public boolean addStudent(Student student) {
System.out.println("Trying .............");
entityManager.persist(student);
return true;
}
}
Servlet (Client)
package com.lmd.dev.controller;
import java.io.IOException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.lmd.dev.ejb.domain.Student;
import com.lmd.dev.ejb.session.ManageStudentSessionBeanLocal;
/**
*
*
*
*/
public class ManageStudentServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
#EJB(mappedName="ManageStudentSessionBean/local")
private ManageStudentSessionBeanLocal manageStudentSessionBeanLocal;
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String message = "";
String firstName = request.getParameter("fname");
String lastName = request.getParameter("lname");
String email = request.getParameter("email");
Student student = new Student();
student.setFirstName(firstName);
student.setLastName(lastName);
student.setEmail(email);
if (manageStudentSessionBeanLocal != null && manageStudentSessionBeanLocal.addStudent(student)) {
message = "Student Successfuly Added";
} else {
message = "Student Adding Failed";
}
request.setAttribute("message", message);
RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
rd.forward(request, response);
}
}
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>x3</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>ManageStudentServlet</display-name>
<servlet-name>ManageStudentServlet</servlet-name>
<servlet-class>com.lmd.dev.controller.ManageStudentServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ManageStudentServlet</servlet-name>
<url-pattern>/ManageStudentServlet</url-pattern>
</servlet-mapping>
</web-app>
You can find source code on git as well
Source Code
When we package an EAR file out of EJB modules then lookup method for the client changes slightly. We can always check it in the console what path we should refer to for injection.Look up method for EJB injection in Servlet for EAR packaging would be something like this.
#EJB(mappedName="YOUR_EAR_NAME/ManageStudentSessionBean/local")
I have an ant script:
<?xml version="1.0" encoding="UTF-8"?>
<project name="AntTest" basedir="." default="clean">
<property name="src.dir" value="src"/>
<property name="classes.dir" value="classes"/>
<target name="clean" description="delete all generated files">
<delete dir="${classes.dir}" failonerror="false"/>
<echo message="Hello" />
<delete dir="${ant.project.name}.jar"/>
</target>
<target name="compile" description="compile the task">
<mkdir dir="${classes.dir}"/>
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}"/>
</target>
<target name="jar" description="create jars of task" depends="compile">
<jar destfile="${ant.project.name}.jar" basedir="${classes.dir}" />
</target>
<target name="use" description="use the created jars" depends="jar">
<taskdef name="ntTest" classname="AntTest" classpath="${ant.project.name}.jar" />
<ntTest/>
</target>
</project>
And output is
Buildfile: D:\Work\D3000\AntTest\Build.xml
clean:
[delete] Deleting directory D:\Work\D3000\AntTest\classes
[echo] Hello
compile:
[mkdir] Created dir: D:\Work\D3000\AntTest\classes
[javac] Compiling 1 source file to D:\Work\D3000\AntTest\classes
compile:
jar:
[jar] Building jar: D:\Work\D3000\AntTest\AntTest.jar
compile:
jar:
use:
BUILD FAILED
D:\Work\D3000\AntTest\Build.xml:24: taskdef class AntTest cannot be found
using the classloader AntClassLoader[D:\Work\D3000\AntTest\AntTest.jar]
Total time: 758 milliseconds
Can anybody tell me why this error is coming:
BUILD FAILED D:\Work\D3000\AntTest\Build.xml:24: taskdef class AntTest
cannot be found using the classloader
AntClassLoader[D:\Work\D3000\AntTest\AntTest.jar]
My class file contains class named AntTest
Seems like the classname is wrong, you need the full qualified classname.
instead of :
<taskdef name="ntTest" classname="AntTest" classpath="${ant.project.name}.jar"/>
try :
<taskdef name="ntTest" classname="com.yourdomain.AntTest" classpath="${ant.project.name}.jar"/>
I'm looking to introduce Jbehave in my project, and I am preparing a simple POC.
Using: jbehave 3.9.3, ant 1.9.2, IDE eclipse kepler.
I can successfully run the tests from within Eclipse (I've also annotated my test class with #RunWith(JUnitReportingRunner.class) ).
I have, however, some issues when I try running the same via ant.
this is the ant file I'm using:
<property name="src.dir" value="${basedir}/bdd/jbtest"/>
<property name="jbehave.version" value="3.9.3"/>
<target name="clean">
<delete dir="target" />
</target>
<target name="setup">
<artifact:dependencies filesetId="dependency.fileset" useScope="test">
<dependency groupId="org.jbehave" artifactId="jbehave-ant" version="${jbehave.version}"/>
<dependency groupId="org.jbehave" artifactId="jbehave-core" version="${jbehave.version}" classifier="resources" type="zip"/>
<dependency groupId="org.jbehave.site" artifactId="jbehave-site-resources" version="3.1.1" type="zip"/>
</artifact:dependencies>
<mkdir dir="target" />
<mkdir dir="target/classes" />
<mkdir dir="target/lib" />
<copy todir="target/lib">
<fileset refid="dependency.fileset" />
<mapper type="flatten" />
</copy>
<!-- copy todir="${src.dir}">
<fileset dir="../core/src/main/java">
</fileset>
</copy> -->
<copy todir="target/classes">
<fileset dir="${src.dir}">
<include name="**/*.story" />
<include name="**/*.properties" />
<include name="**/*.xml" />
</fileset>
</copy>
<path id="story.classpath">
<fileset dir="${basedir}/lib" includes="**/*.jar" />
<pathelement location="${basedir}/bin" />
</path>
<classloader classpathref="story.classpath" />
<pathconvert targetos="unix" property="story.classpath.unix" refid="story.classpath">
</pathconvert>
<echo>Using classpath: ${story.classpath.unix}</echo>
</target>
<target name="compile" depends="setup">
<javac includeantruntime="false" srcdir="${src.dir}" destdir="bin" debug="on" debuglevel="lines,source" includes="**/*.java,**/*.xml">
<classpath refid="story.classpath" />
</javac>
</target>
<target name="reports-resources" depends="setup">
<unzip src="${org.jbehave:jbehave-core:zip:resources}" dest="${basedir}/target/jbehave/view/" />
<unzip src="${org.jbehave.site:jbehave-site-resources:zip}" dest="${basedir}/target/jbehave/view/" />
</target>
<target name="run-stories-as-embeddables" depends="compile, reports-resources">
<taskdef name="runStoriesAsEmbeddables" classname="org.jbehave.ant.RunStoriesAsEmbeddables" classpathref="story.classpath" />
<runStoriesAsEmbeddables sourceDirectory="${src.dir}" includes="**/Myjb.java" excludes="**/examples*" batch="false" ignoreFailureInStories="true" ignoreFailureInView="true" generateViewAfterStories="true"
systemproperties="java.awt.headless=true,project.dir=${basedir}" />
</target>
<target name="run-stories-as-paths" depends="compile, reports-resources" >
<taskdef name="runStoriesAsPaths" classname="org.jbehave.ant.RunStoriesAsPaths" classpathref="story.classpath" />
<runStoriesAsPaths sourceDirectory="${src.dir}"
includes="**/*.story" batch="false" ignoreFailureInStories="true" ignoreFailureInView="true" generateViewAfterStories="true"
systemproperties="java.awt.headless=true,project.dir=${basedir}"
>
</runStoriesAsPaths>
</target>
<target name="stepdoc" depends="compile">
<taskdef name="reportStepdocs" classname="org.jbehave.ant.ReportStepdocs" classpathref="story.classpath" />
<reportStepdocs embedderClass="org.jbehave.examples.core.CoreEmbedder" />
<taskdef name="reportRenderer" classname="org.jbehave.ant.ReportRendererTask" classpathref="story.classpath" />
<reportRenderer outputDirectory="${basedir}/target/jbehave"
formats="txt,html" templateProperties="defaultFormats=stats"
ignoreFailure="true"/>
</target>
<target name="build" depends="run-stories-as-paths,stepdoc" />
</project>
issue #1: I can't specify the format
run-stories-as-paths:
[runStoriesAsPaths] Running stories as paths using embedder Embedder[storyMapper=StoryMapper,storyRunner=StoryRunner,embedderMonitor=AntEmbedderMonitor,classLoader=EmbedderClassLoader[urls=[],parent=java.net.URLClassLoader#1a8fa0f0],embedderControls=UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=true,verboseFailures=false,verboseFiltering=false,storyTimeoutInSecs=300,failOnStoryTimeout=false,threads=1]],embedderFailureStrategy=<null>,configuration=org.jbehave.core.configuration.MostUsefulConfiguration#5556d74f,candidateSteps=<null>,stepsFactory=<null>,metaFilters=<null>,systemProperties={java.awt.headless=true, project.dir=D:danielewsjbtest},executorService=<null>,executorServiceCreated=false,storyManager=<null>]
[runStoriesAsPaths] Found story paths: [Example.story, Sample.story]
[runStoriesAsPaths] Processing system properties {java.awt.headless=true, project.dir=D:danielewsjbtest}
[runStoriesAsPaths] System property 'java.awt.headless' set to 'true'
[runStoriesAsPaths] System property 'project.dir' set to 'D:danielewsjbtest'
[runStoriesAsPaths] Using controls UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=true,verboseFailures=false,verboseFiltering=false,storyTimeoutInSecs=300,failOnStoryTimeout=false,threads=1]]
[runStoriesAsPaths] Generating reports view to 'D:\daniele\ws\jbtest\target\jbehave' using formats '[]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports-with-totals.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}'
[runStoriesAsPaths] Reports view generated with 0 stories (of which 0 pending) containing 0 scenarios (of which 0 pending)
I did not find a way to pass the format as I'm doing in the java class and that get's ignored, so it does not generate any report.
issue #2 story finding exception
when I run
ant -f jb_ant.xml -lib lib run-stories-as-paths
just after the output shown above, I get an exception
BUILD FAILED
D:\daniele\ws\jbtest\jb_ant.xml:74: org.jbehave.core.io.StoryResourceNotFound: Story path 'Example.story' not found by class loader EmbedderClassLoader[urls=[],parent=java.net.URLClassLoader#1a8fa0f0]
at org.jbehave.core.io.LoadFromClasspath.resourceAsStream(LoadFromClasspath.java:44)
at org.jbehave.core.io.LoadFromClasspath.loadResourceAsText(LoadFromClasspath.java:29)
at org.jbehave.core.io.LoadFromClasspath.loadStoryAsText(LoadFromClasspath.java:38)
at org.jbehave.core.embedder.StoryRunner.storyOfPath(StoryRunner.java:192)
at org.jbehave.core.embedder.StoryManager.storyOfPath(StoryManager.java:49)
at org.jbehave.core.embedder.StoryManager.runningStoriesAsPaths(StoryManager.java:101)
at org.jbehave.core.embedder.StoryManager.runStories(StoryManager.java:78)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:203)
at org.jbehave.ant.RunStoriesAsPaths.execute(RunStoriesAsPaths.java:16)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
which is puzzling me because jbehave had just listed the found the story while executing the task.
I can post the both the Java classes and stories if this may help diagnose the problem.
Any ideas what am I doing wrong?
After a while, I found an answer to these issues:
the org.jbehave.core.io.StoryResourceNotFound exception was resolved by implementing a StoryFinder Class (code below)
to generate the reports, I had to implement an Embedder class (code below) and specify the formats there (apparently there is no way to pass this directly to the Ant tasks.
Hope this helps anyone else with similar problems.
StoryFinder
package jbtest;
import org.jbehave.core.io.StoryFinder;
import java.util.*;
public class MyStoryFinder extends StoryFinder {
#Override
protected List<String> scan(String basedir, List<String> includes,
List<String> excludes) {
//List<String> defaultStories = super.scan(basedir, includes, excludes);
//String myStories = System.getProperty("com.sarang.stories");
return Arrays.asList("jbtest/Example.story,jbtest/Sample.story".split(","));
}
}
Embedder
package jbtest;
import java.text.SimpleDateFormat;
import java.util.Properties;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.Embedder;
import org.jbehave.core.embedder.EmbedderControls;
import org.jbehave.core.io.CodeLocations;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.parsers.RegexPrefixCapturingPatternParser;
import org.jbehave.core.reporters.CrossReference;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.jbehave.core.steps.ParameterConverters;
import org.jbehave.core.steps.SilentStepMonitor;
public class MyEmbedder extends Embedder {
#Override
public EmbedderControls embedderControls() {
return new EmbedderControls().doIgnoreFailureInStories(true).doIgnoreFailureInView(true);
}
#Override
public Configuration configuration() {
Class<? extends MyEmbedder> embedderClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
return new MostUsefulConfiguration()
.useStoryReporterBuilder(
new StoryReporterBuilder()
.withDefaultFormats()
.withViewResources(viewResources).withFormats(Format.CONSOLE, Format.HTML, Format.XML)
.withFailureTrace(true)
) ;
}
#Override
public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new ExampleSteps(), new SampleSteps());
}
}
Then I modified the Ant task as follows:
<target name="run-stories-as-paths" depends="compile, reports-resources" >
<taskdef name="runStoriesAsPaths" classname="org.jbehave.ant.RunStoriesAsPaths" classpathref="story.classpath" />
<runStoriesAsPaths
sourceDirectory="${src.dir}"
includes="**/*.story"
ignoreFailureInStories="true"
ignoreFailureInView="true"
generateViewAfterStories="true"
storyfinderclass="jbtest.MyStoryFinder"
verbosefailures="true"
embedderclass="jbtest.MyEmbedder"
>
</runStoriesAsPaths>
</target>
I'm trying to import Google's ZXing.
I downloaded the latest release from https://code.google.com/p/zxing/downloads/detail?name=ZXing-2.2.zip&can=2&q=
From the cmd prompt I navigated to the root directory of the downloaded zxing and tried to execute
ant -f core\build.xml
PROBLEM :
Buildfile : build.xml does not exist!
Build failed
My zxing-2.2/core file contains :
src
test
pom.xml
Questions:
How to build a file that is missing?
Is it a problem from the zxing-2.2.jar I downloaded?
This problem happened to me too, I solved it by creating the build.xml file inside core folder
change name="whatever you want" in the second line, here it's "project"
code of build.xml:
<?xml version="1.0" encoding="utf-8" ?>
<project name="project" default="jar" basedir=".">
<target name="compile" description="Compile source">
<mkdir dir="bin" />
<javac srcdir="src" includes="**" destdir="bin"/>
<copy todir="bin">
<fileset dir="src" />
</copy>
</target>
<target name="jar" description="Package into JAR" depends="compile">
<jar destfile="project.jar" basedir="bin" compress="true" />
</target>
</project>
Run the build command again and see if it works.
Please do consider that you can always use the pom.xml to achieve the same. This is the method prescribed in the official zxing documentation
https://code.google.com/p/zxing/wiki/GettingStarted
The commands I have used are as follows:
cd core
mvn -DskipTests -Dgpg.skip=true install
That's it, you are done. Obviously, maven is to be installed before using the code
I tried the accepted answer, but unfortunately it not worked. Actually the jar was built successfully, but it was not built into the apk when Eclipse built the project. This was when i referenced ZXing as a library project. I managed to write an ant script which works, so i share it here:
<?xml version="1.0" encoding="utf-8" ?>
<project name="core" basedir="." default="dist" >
<property name="dist.dir" value="dist" />
<property name="src.dir" value="src" />
<property name="build.dir" value="bin" />
<target name="dist" depends="clean, package" />
<target name="clean" >
<delete dir="${build.dir}" />
</target>
<target name="init" >
<mkdir dir="${build.dir}" />
</target>
<target name="compile" >
<javac debug="off" destdir="${build.dir}" source="1.6" srcdir="${src.dir}" target="1.6" />
</target>
<target name="package" depends="init, compile" >
<jar basedir="${build.dir}" destfile="${dist.dir}/core.jar" />
</target>
</project>
If you just need the core.jar from zxing, you can skip that process and get the pre-built JARs from the GettingStarted wiki page
Core.jar is the library solution to integrate zxing in your app
(the other option is via Intent but BarcodeScanner.apk is needed)
For zxing2.2, you can obtain the core.jar from the zxing Maven repository here
Zxing 2.2 and above don't include core/build.xml
If the original file is necessary I recommend using Zxing 2.1, which can be found here:
https://code.google.com/p/zxing/downloads/detail?name=ZXing-2.2.zip&can=2&q=