title: Java Ant XML Build Failed, Cause: The name is undefined
body: <pre><code>    &lt;path id="checkstyle.classpath"&gt;
      &lt;fileset dir="${basedir}/lib/"&gt;
          &lt;include name="checkstyle-6.12.1-all.jar" /&gt;
      &lt;/fileset&gt;
  &lt;/path&gt; 
  
  &lt;target name="checkstyle"&gt;
          &lt;!-- CheckStyle  --&gt;
          &lt;taskdef resource="checkstyle.properties" classpath="C:\Users\Pil\Desktop\Workspace2\Cs376bDemoApp\lib
               \checkstyle-6.12.1-all.jar" /&gt;
          &lt;checkstyle config="DsrJavaFormattingProfile.xml" classpath="C:\Users\Pil\Desktop\Workspace2\Cs376bDemoApp\lib
               \checkstyle-6.12.1-all.jar" /&gt;
          &lt;fileset dir="${src}" includes="**/*.java" /&gt;
      &lt;/target&gt;
  </code></pre>
  
  <p>This is my checkstyle target in my build.xml file. I have spent the past 6 hours debugging this before resorting to StackOverFlow but my best efforts proved fruitless. I am consistently met with the error report [taskdef] Could not load definitions from resource checkstyle.properties. It could not be found.</p>
  
  <pre><code>BUILD FAILED
  C:\Users\Pil\Desktop\Workspace2\Cs376bDemoApp\build.xml:86: 
  Problem: failed to create task or type checkstyle
  Cause: The name is undefined.
  Action: Check the spelling.
  Action: Check that any custom tasks/types have been declared.
  Action: Check that any &lt;presetdef&gt;/&lt;macrodef&gt; declarations have taken place.
  </code></pre>
  
  <p>My intention for this code is for it to use my DsrJavaFormattingProfile.xml on  the .java files in my src directory. I have tried replacing the class path with the relative path "lib/" and with the checkstyle.classpath path above aswell as every possible other solution I could think of. </p>
  
  <pre><code>&lt;taskdef resource="checkstyle.properties" classpathref="checkstyle.classpath" /&gt;
          &lt;checkstyle config="DsrJavaFormattingProfile.xml" classpathref="checkstyle.classpath" /&gt;
  </code></pre>
  
  <p>also resulted in the same error. Please save me StackOverFlow, I need a hero.
  <a href="https://www.youtube.com/watch?v=OBwS66EBUcY" rel="nofollow noreferrer">https://www.youtube.com/watch?v=OBwS66EBUcY</a></p>
  
  <p>Update: Solved by CAustin</p>
  
  <p>`   </p>
  
  <pre><code>&lt;target name="checkinit"&gt;
          &lt;path id="checkstyle.lib.path"&gt;
              &lt;fileset dir="lib" includes="checkstyle8.8all.jar" /&gt;
          &lt;/path&gt;
          &lt;taskdef resource="com/puppycrawl/
  tools/checkstyle/ant/checkstyle-ant-task.properties" classpathref="checkstyle.classpath" /&gt;
      &lt;/target&gt;
  
      &lt;target name="checkstyle" depends="checkinit"&gt;
          &lt;!-- CheckStyle  --&gt;
          &lt;checkstyle config="${basedir}\DsrCheckStyleConfig.xml" classpathref="checkstyle.lib.path"&gt;
              &lt;path refid="project.sourcepath" /&gt;
              &lt;/checkstyle&gt;
          &lt;/target&gt;`
  </code></pre>