How to generate Make Files?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to generate Make Files?

  1. #1
    aMax Guest

    How to generate Make Files?


    I would like to automate the recompile of large application having several
    packages.

  2. #2
    Paul Clapham Guest

    Re: How to generate Make Files?

    I suspect the reason that Java doesn't have a "make" facility is that mass
    recompiles are rarely necessary. You only need to recompile a class if it
    uses a method of another class and that method no longer exists, or its
    parameter list has changed, and only to track down such errors. (Of course
    this is something that you would try to avoid doing.) The other reason for
    a mass recompile could be when you move to a new version of the compiler.
    In any case, "javac *.java" will recompile all Java sources in a directory.

    aMax <arun@stones.com> wrote in message news:39874381$1@news.devx.com...
    >
    > I would like to automate the recompile of large application having several
    > packages.




  3. #3
    Jo Desmet Guest

    Re: How to generate Make Files?

    One of my first rules is always to do a mass recompile and even delete all
    class files before doing that, unless I am 100% certain that there are no
    dependencies with the parts I do not want to recompile. Here comes the
    important task of carefully designing your packages, separating in logical
    independent units. This will also help you to reuse those packages into
    other projects without modification, or without forcing you to move the
    whole library set into your new project.

    Way to often I see people creating cross-dependencies. Everything works
    while they are coding, but when the release is there the code wont compile
    properly, or the release will show crashes (and you thinking that java can
    not crash).
    At least for the release, there should be a clean-make, but then stress is
    high, and time low ...

    To be honnest, I feel that a makefile doesnt work properly with java, and I
    tend to make script or batch files for each of the packages that I want to
    generate. You can even go further by generating javadoc, jar files and even
    executing test code within the compiled packages to track unexpected changes
    in output. Here is an example batch file (for ms-dossers, but translates
    easelly into csh).

    [start example: make.bat]
    @echo off

    SETLOCAL

    rem This is a bat file wich compiles the entire JMEP project and place
    rem it in a jar file. The final results are tested and any results can
    rem be found at %TESTDIR%\report.txt

    rem This batch file is meant to run on any configuration. You only need to
    rem change the JAVADIR and BASE environment variable to reflect your set up.

    rem To let this work with the zip file I always send to you, you have to
    rem extract the whole contents of the zip file to a directory and define
    rem BASE to point to the same directory (here this directory is
    rem d:\data\projects\jmep).

    rem The JAVADIR environment variable has to point to the base installation
    rem directory of your java distribution. The java executables should be
    found
    rem at %JAVADIR%\bin

    rem Define where you can find the java binaries
    rem TODO: Change this to let this point to your path
    set JAVADIR=C:\jdk1.3

    rem Define the base directory of the projects
    rem TODO: Change this to let this point to your path
    set BASE=c:\data\development\jmep

    rem Define where the class files and jar files are outputted
    rem DO NOT CHANGE
    set CLASSES=%BASE%\classes

    rem Define a path for temporary storage of class files before
    rem making a jar file from it.
    rem DO NOT CHANGE
    set CLASSES_TMP=%BASE%\jartmp

    rem Define a path for temporary storage of class files before
    rem making a jar file from it.
    rem DO NOT CHANGE
    set TESTDIR=%BASE%\test

    rem Define a path for temporary storage of class files before
    rem making a jar file from it.
    rem DO NOT CHANGE
    set HTMLDIR=%BASE%\html

    rem Define the java compile command
    rem REMARK: if needed change javac to javac-ea for better compiler.
    rem DO NOT CHANGE
    set JAVAC="%JAVADIR%\bin\javac" -O -deprecation

    rem Define the javadoc command
    rem DO NOT CHANGE
    set JAVADOC="%JAVADIR%\bin\javadoc"

    rem Define the jar command
    rem DO NOT CHANGE
    set JAR="%JAVADIR%\bin\jar"

    rem Define the java run command
    rem DO NOT CHANGE
    set JAVA="%JAVADIR%\bin\java"

    rem Do some clean-up
    rem DO NOT CHANGE
    echo Cleaning up ...
    if exist %CLASSES_TMP% rmdir /S /Q %CLASSES_TMP%
    if exist %CLASSES% rmdir /S /Q %CLASSES%
    if exist %HTMLDIR% rmdir /S /Q %HTMLDIR%
    mkdir %CLASSES%
    mkdir %HTMLDIR%

    rem Compile the whole JMEP project and store it in the temporary
    rem folder, then make a jar file from it.
    rem DO NOT CHANGE
    echo Making the jmep project ...
    mkdir %CLASSES_TMP%
    set CLASSPATH=%CLASSES_TMP%
    set SOURCE=%BASE%\java\com\neemsoft\jmep\*.java
    %JAVAC% -d "%CLASSES_TMP%" -classpath "%CLASSPATH%" %SOURCE%
    %JAR% -cf0 "%CLASSES%\jmep.jar" -C "%CLASSES_TMP%" com
    rmdir /S /Q "%CLASSES_TMP%"

    rem Making the documentation
    rem DO NOT CHANGE
    echo Making the documentation...
    set CLASSPATH=%CLASSES%\jmep.jar
    %JAVADOC% -classpath "%CLASSPATH%" -d %HTMLDIR%
    com.neemsoft.jmep -sourcepath %BASE%\java

    rem make the TestJMEP application and run it to test if there
    rem are any problems.
    rem DO NOT CHANGE
    echo Making the test application ...
    set CLASSPATH=%CLASSES%
    set CLASSPATH=%CLASSPATH%;%CLASSES%\jmep.jar
    set SOURCE=%BASE%\java\TestJMEP.java
    %JAVAC% -d %CLASSES% -classpath "%CLASSPATH%" %SOURCE%
    echo Testing the jmep.jar library ...
    %JAVA% -classpath "%CLASSPATH%" TestJMEP %TESTDIR%

    rem make the CLJMEP example application
    rem DO NOT CHANGE
    echo Making the example application ...
    set CLASSPATH=%CLASSES%
    set CLASSPATH=%CLASSPATH%;%CLASSES%\jmep.jar
    set SOURCE=%BASE%\java\CLJMEP.java
    %JAVAC% -d %CLASSES% -classpath "%CLASSPATH%" %SOURCE%

    echo ======================================================================
    echo Test results are in %TESTDIR%\report.txt,
    echo check to see if any problems.
    echo You can extend the tests by adding equations into intput.txt and the
    echo expected results into refer.txt.
    echo jmep.jar can be found at %CLASSES%,
    echo you can copy it into %JAVADIR%\jre\lib\ext,
    echo to install it as a java extension.
    echo You can start the example with the example.bat script file.
    echo ======================================================================

    ENDLOCAL

    [end example]
    ----- Original Message -----
    From: "Paul Clapham" <pclapham@core-mark.com>
    Newsgroups: java.enterprise
    Sent: Friday, August 04, 2000 10:34 AM
    Subject: Re: How to generate Make Files?


    > I suspect the reason that Java doesn't have a "make" facility is that mass
    > recompiles are rarely necessary. You only need to recompile a class if it
    > uses a method of another class and that method no longer exists, or its
    > parameter list has changed, and only to track down such errors. (Of

    course
    > this is something that you would try to avoid doing.) The other reason

    for
    > a mass recompile could be when you move to a new version of the compiler.
    > In any case, "javac *.java" will recompile all Java sources in a

    directory.
    >
    > aMax <arun@stones.com> wrote in message news:39874381$1@news.devx.com...
    > >
    > > I would like to automate the recompile of large application having

    several
    > > packages.

    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center