我有这个:
javac -d "$PWD/target/classes" \
-cp "$CLASSPATH:$PWD/src/main/java" \
"$(find "$PWD/src/main/java/huru" -name '*.java')"
但我得到:
javac: file not found: /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/Foo.java
/home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/BaseModel.java
/home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/InterfaceContainer.java
/home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/KCClassEntity.java
/home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/BaseEntity.java
/home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/UserModel.java
/home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/query/QueryBuilder.java
/home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/TestVerticle.java
/home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/middleware/JWTHandler.java
所以我尝试使用xargs将它放在一行:
javac -d "$PWD/target/classes" \
-cp "$CLASSPATH:$PWD/src/main/java:$m2" \
"$(find "$PWD/src/main/java/huru" -name '*.java' | xargs)"
但后来我得到:
javac: file not found: /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/Foo.java /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/BaseModel.java /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/InterfaceContainer.java /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/KCClassEntity.java /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/entity/BaseEntity.java /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/middleware/ErrorHandler.java /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/util/Asyncc.java /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/routes/IBasicHandler.java /home/oleg/codes/oresoftware/vertx.api/src/main/java/huru/routes/RouteHelper.java
其中xargs将所有内容放在一行中。所有这些java文件都存在,路径是正确的,但很明显find的结果不起作用。有谁知道怎么做对吗?
所以一种技术是使用临时文件(虽然它很有用但是很有效):
find . -name '.java' > my.files
javac @my.files
是的,根据javac规范,@字符是必要的,所以java知道它是一个要读取的文件。
但我仍在寻找一种方法来直接找到javac的结果而不必使用临时文件。