1
我想從我的maven文件中執行protoc(protobuffer編譯器)。我包埋在類似下面的如何在maven中從protoc生成多個類?
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
.... <!-- I have several of these blocks - how can I reduce them to one? -->
<exec executable="protoc/protoc.exe">
<arg value="--java_out=target/generated-sources"/>
<arg value="src/main/protos/Proto1.proto"/>
<arg value="--proto_path=src/main/protos"/>
</exec>
<exec executable="protoc/protoc.exe">
<arg value="--java_out=target/generated-sources"/>
<arg value="src/main/protos/Proto2.proto"/>
<arg value="--proto_path=src/main/protos"/>
</exec>
.....
</tasks>
<sourceRoot>target/generated-sources</sourceRoot>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
pom.xml中的Ant任務我怎麼能定義一個循環或東西,所以行家迭代遍佈在目錄中的文件?
我知道這裏有一個protobuffer maven插件,但我不得不聲明一個外部存儲庫來使用它,這目前不是一個選項。
您的代碼看起來更像是一個Ant任務。如果是這樣,這是一個螞蟻問題。你可以看一下apply:http://ant.apache.org/manual/Tasks/apply.html –
在Maven中目前不存在迭代文件的可能性。 – khmarbaise
問題改寫 – morpheus05