Commit 8ce5cc7e authored by lichenchong's avatar lichenchong
Browse files

Sync and build proto file from proto file repo when we use maven command

line "mvn clean compile/package".
parent f9089be9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -233,3 +233,6 @@ Usage of proto scripts
   
2. Build protocol file locally, including compile kinetic.proto, kineticDb.proto, kineticIo.proto.
   $sh buildProto.sh
   
3. Sync protocol file from Kinetic-Protocol github repo and then build proto file.
   $sh syncProtoFromRepoAndBuild.sh
 No newline at end of file
+50 −0
Original line number Diff line number Diff line
#! /usr/bin/env bash
BASE_DIR=`dirname "$0"`/..
BASE_DIR=`cd "$BASE_DIR"; pwd`
#echo "BASE_DIR=$BASE_DIR"

PROTO_DIR=$BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/
PROTO_FILE=$BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/kinetic.proto
CLONE_DIR=$BASE_DIR/bin/Kinetic-ProtocoL
PROTO_COMPILE_DIR=$BASE_DIR/kinetic-common/src/main/java/

if [ -f "$PROTO_FILE" ]; then
    echo "$PROTO_FILE exists, does not sync and build, exit."
    exit 0
fi

if [ -d "$CLONE_DIR" ]; then
    rm -rf "$CLONE_DIR"
fi

if [ $# -eq 0 ]; then
    echo "Clone protocol file from github:"
    git clone https://github.com/Seagate/Kinetic-Protocol.git $CLONE_DIR
fi

if [ $# -eq 1 ]; then
    echo "Clone protocol file $1 from github:"
    git clone https://github.com/Seagate/Kinetic-Protocol.git $CLONE_DIR
    cd $CLONE_DIR
    git checkout $1
    echo "$1"
fi

cp $CLONE_DIR/kinetic.proto $PROTO_FILE

rm -rf "$CLONE_DIR"

echo "Sync protocol file finished."

echo "Compile protocol file: $PROTO_FILE."
protoc --proto_path=$PROTO_DIR --java_out=$PROTO_COMPILE_DIR $PROTO_FILE

echo "Compile protocol file: $PROTO_DIR/kineticDb.proto."
protoc --proto_path=$PROTO_DIR --java_out=$PROTO_COMPILE_DIR $PROTO_DIR/kineticDb.proto

echo "Compile protocol file: $PROTO_DIR/kineticIo.proto."
protoc --proto_path=$PROTO_DIR --java_out=$PROTO_COMPILE_DIR $PROTO_DIR/kineticIo.proto

echo "Compile finished."

exit 0
+53 −0
Original line number Diff line number Diff line
@@ -43,7 +43,60 @@
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>exec-maven-plugin</artifactId>
				<groupId>org.codehaus.mojo</groupId>
				<version>1.1.1</version>
				<executions>
					<execution>
						<id>sync-build-protocol</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>exec</goal>
						</goals>
						<configuration>
							<executable>${project.parent.basedir}/bin/syncProtoFromRepoAndbuild.sh</executable>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
		<pluginManagement>
			<plugins>
				<!--This plugin's configuration is used to store Eclipse m2e settings 
					only. It has no influence on the Maven build itself. -->
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>
											org.codehaus.mojo
										</groupId>
										<artifactId>
											exec-maven-plugin
										</artifactId>
										<versionRange>
											[1.1,)
										</versionRange>
										<goals>
											<goal>exec</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore />
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
	<dependencies>
		<dependency>