Makefile - hqzhang/cloudtestbed GitHub Wiki
1.make for each item
LIST=hello world
all: hello world
echo $^
$(SUBDIRS):
gcc -o my [email protected]
run:
./my
- make for each subdir
SUBDIRS := $(wildcard */.)
all: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
.PHONY: all $(SUBDIRS)
- universal makefile
- makefile advanced
- maven compiler
1). write pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jenkov</groupId>
<artifactId>hello-world</artifactId>
<version>1.0.0</version>
</project>
2). mkdir -p src/main/java/com/jenkov/app
and then create App.java in it
package com.jenkov.app;
public class App {
public static void main(String args[]){
System.out.println("Hello World, Maven");
}
}
3) mvn compile //compile it into target/classes
4) mvn dependency:tree /f/show deps
5) mvn package // jar it into target/
6) mvn exec:exec //run it by pom.xml
java -cp target/classes com.jenkov.app.App //run it by class
java -cp target/my-app-1.0-SNAPSHOT.jar com.jenkov.app.App //run it by jar
- ant compiler
write build.xml file
<?xml version="1.0"?>
<project name="Hello" default="compile">
<target name="clean" description="remove intermediate files">
<delete dir="classes"/>
</target>
<target name="clobber" depends="clean" description="remove all artifact files">
<delete file="hello.jar"/>
</target>
<target name="compile" description="compile the Java source code to class files">
<mkdir dir="classes"/>
<javac srcdir="." destdir="classes"/>
</target>
<target name="jar" depends="compile" description="create a Jar file for the application">
<jar destfile="hello.jar">
<fileset dir="classes" includes="**/*.class"/>
<manifest>
<attribute name="Main-Class" value="HelloProgram"/>
</manifest>
</jar>
</target>
</project>
write code file Hello.java
public class Hello {
public static void main(String[] args){
System.out.println("Hello World");
}
}
compile and running
ant compile
ant jar
compile jar are defined in build.xml