forked from JavaTX/JavaCompilerCore
added makefile that can compile all .java files and maintain the package structure
This commit is contained in:
parent
a84d1ffdd7
commit
8ea459fcd7
33
makefile
Normal file
33
makefile
Normal file
@ -0,0 +1,33 @@
|
||||
JFLAGS = -g
|
||||
JC = javac
|
||||
|
||||
SRCDIR = src/main/java
|
||||
DESTDIR = out
|
||||
|
||||
# Use find to locate all .java files recursively
|
||||
SOURCES := $(shell find $(SRCDIR) -name '*.java')
|
||||
RELATIVE_SOURCES := $(patsubst $(SRCDIR)/%,%,$(SOURCES))
|
||||
|
||||
# Convert .java files to .class files with the same directory structure
|
||||
CLASSES := $(patsubst $(SRCDIR)/%.java,$(DESTDIR)/%.class,$(SOURCES))
|
||||
|
||||
# Create a list of directories that need to be created in the destination directory
|
||||
DIRS := $(sort $(dir $(CLASSES)))
|
||||
|
||||
all:
|
||||
@echo "$(RELATIVE_SOURCES)"
|
||||
|
||||
default: classes
|
||||
|
||||
# Rule for creating directories
|
||||
$(DIRS):
|
||||
@mkdir -p $@
|
||||
|
||||
# Rule for compiling Java files
|
||||
$(DESTDIR)/%.class: $(SRCDIR)/%.java | $(DIRS)
|
||||
$(JC) -nowarn -d $(DESTDIR) -cp "src/main/java:target/dependencies/*" $(JFLAGS) $<
|
||||
|
||||
classes: $(CLASSES)
|
||||
|
||||
clean:
|
||||
$(RM) -r $(DESTDIR)
|
20
pom.xml
20
pom.xml
@ -48,6 +48,23 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@ -73,6 +90,9 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-maven-plugin</artifactId>
|
||||
<version>4.11.1</version>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>antlr</id>
|
||||
|
Loading…
Reference in New Issue
Block a user