JAR

NAME
SYNOPSIS
DESCRIPTION
EXAMPLES
NOTES
SEE ALSO

Nokia nmake 15 JAR(1)

NAME

:JAR: − build and maintain jar files

SYNOPSIS

name.jar :JAR: [ manifest-file ] [ JARROOT=root_dir ] files

DESCRIPTION

The :JAR: assertion builds and maintains jar files, with support for viewpathing, index files, and manifest files. Multiple :JAR: assertions are supported in a single makefile.
name
.jar

The target jar file to be created.

files

Files to include in the jar, typically class files, specified using full ksh(1)-style shell patterns. Non-absolute paths are relative to the current directory and must begin with a prefix of $(JARROOT). Paths in the resulting jar file are relative to $(JARROOT).

manifest-file

The name of manifest file, used to merge its contents to the target jar file as one part of the internal manifest file. By default, filenames with suffix .mf are automatically recognized as manifest files. In general, filenames marked with the .JARMANIFEST attribute are taken as manifest files.

JARROOT=root_dir

The root of the package of prerequisite files for the jar archive specified relative to the current directory. The default is the current directory.

Removing a File from the Build
Similar to :JAVA:, Java source files containing the string ‘‘#empty’’ outside of comment sections and as the first item on a line are excluded from jar archives when archiving source files. Changing a file to ‘‘#empty’’ masks old versions of the file in the viewpath. See the JAVA(1) manual page for more information.

By default class files are not affected. To exclude ‘‘#empty’’ class files include the following in the makefiles:

.ATTRIBUTE.%.class : .SCAN.java

If a member of a jar archive is changed to ‘‘#empty’’ in an incremental build then it is removed from the target jar file. If all members become ‘‘#empty’’ then a zero sized file is created for the target jar to mask out old versions of the jar in the viewpath.

Variables and Atoms
The following user-settable variables may be used:

JAR

Jar tool. Defaults to jar.

JARFLAGS

Extra flags for jar command. Defaults to null.

jarappend

Controls whether an existing jar file will be replaced or appended. Setting this to 1 will append to an existing jar file that is out of sync with the current state file thus allowing multiple makefiles to maintain members in the same jar. Setting to 0 or null will clobber an existing jar file that is out of sync with the current state file and remake it. Defaults to null.

The following attribute may be used:
.JARMANIFEST

Attribute to identify jar manifest file defined by user.

EXAMPLES

The following makefile generates one.jar from all .class files recursively under the classes/com subdirectory. The files in the archive are rooted at classes so their paths start with com/.

one.jar :JAR: classes/com/*.class JARROOT=classes

The following makes two.jar and three.jar with the archive members in both rooted at $(VROOT)/classes. two.jar contains all .class and .png files recursively under $(VROOT)/classes/com/two. three.jar contains all .class files under $(VROOT)/classes/com/three with three.mf merged with the internal jar manifest.

JARROOT = $(VROOT)/classes
:ALL:
two.jar   :JAR: $(VROOT)/classes/com/two/*.(class|png)
three.jar :JAR: $(VROOT)/classes/com/three/*.class three.mf

The last makefile makes four.jar from the .class files directly inside the com/company/proj1 and com/company/proj2 directories. The nmake variable ns matches everything except / so this operation is not recursive. All .png files recursively under images are also included in the archive. JARROOT is not specified so the files are rooted in the archive as specified on the rhs.

four.jar :JAR: com/company/proj[12]/$(ns).class image/*.png

NOTES

It is recommended that rhs files be relative paths to facilitate viewpath search, and JARROOT is set to their parent directory.

If a rhs file contains no ksh pattern characters then pattern matching is not used to generate a list of prerequisites and the prerequisite is taken as specified. If such a file does not exist in the viewpath nmake will issue an error for the missing file. If the rhs file contains a ksh pattern then pattern matching is used to generate the prerequisite list and no errors are generated for missing files. A warning is generated if no files are found to match the rhs patterns.

The * rhs pattern matches /. Thus, dir/*.class matches all class files recursively under dir. The shell pattern *([!/]) matches the maximum length character string not containing a /. For convenience, the nmake variable ns is set to this pattern. For example, dir/$(ns).class matches all classes directly contained in dir.

JARROOT can be set as a standard variable in the makefile, thus, it will be in effect for all :JAR: assertions. If put in the prerequisite list of a :JAR: assertion, it will be used solely for that assertion.

JARMANIFEST can be used flexibly in user makefiles.

common usage: manifest-file : .JARMANIFEST
extended usage: .ATTRIBUTE.%.pattern : .JARMANIFEST
For .mf files, .JARMANIFEST is set by default, as: .ATTRIBUTE.%.mf : .JARMANIFEST

The operator :ALL: can build all targets of :JAR: assertions automatically. If not specified, the first target will be taken as the main target by default.

If the class files in the prerequisite list do not exist, :JAVA: should first be used in a different makefile to build them. Currently, :JAR: and :JAVA: assertions cannot be used in the same makefile.

Several JDK versions are supported.

Setup and use on the Interix and UWIN based versions of Nokia nmake is similar to usage on the UNIX® version. See the JAVA(1) manual page for more information.

SEE ALSO

JAVA(1), npwj(1), nmake(1)
nmake User’s Guide
nmake Reference Manual
nmake Web Site


nmake 15 June 2013 JAR(1)