1+ #
2+ # Licensed to the Apache Software Foundation (ASF) under one
3+ # or more contributor license agreements. See the NOTICE file
4+ # distributed with this work for additional information
5+ # regarding copyright ownership. The ASF licenses this file
6+ # to you under the Apache License, Version 2.0 (the
7+ # "License"); you may not use this file except in compliance
8+ # with the License. You may obtain a copy of the License at
9+ #
10+ # http://www.apache.org/licenses/LICENSE-2.0
11+ #
12+ # Unless required by applicable law or agreed to in writing,
13+ # software distributed under the License is distributed on an
14+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+ # KIND, either express or implied. See the License for the
16+ # specific language governing permissions and limitations
17+ # under the License.
18+ #
19+
20+ if (NOT THRIFTMAVENPLUGIN_INSTALL_DIR)
21+ if (IS_ABSOLUTE "${CONTRIB_INSTALL_DIR} " )
22+ set (THRIFTMAVENPLUGIN_INSTALL_DIR "${CONTRIB_INSTALL_DIR} /thrift-maven-plugin" )
23+ else ()
24+ set (THRIFTMAVENPLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX} /${CONTRIB_INSTALL_DIR} /thrift-maven-plugin" )
25+ endif ()
26+ endif ()
27+
28+ set (PRELEASE "true" )
29+ if (CMAKE_BUILD_TYPE MATCHES DEBUG)
30+ set (PRELEASE "false" )
31+ endif ()
32+
33+ set (MAVEN_OUTPUT_JAR "${CMAKE_CURRENT_SOURCE_DIR} /target/thrift-maven-plugin-${thrift_VERSION} .jar" )
34+
35+ file (GLOB_RECURSE THRIFTMAVENPLUGIN_SOURCES LIST_DIRECTORIES false
36+ "${CMAKE_CURRENT_SOURCE_DIR} /src/*"
37+ "${CMAKE_CURRENT_SOURCE_DIR} /pom.xml" )
38+
39+ add_custom_command (OUTPUT "${MAVEN_OUTPUT_JAR} "
40+ COMMENT "Building Maven plugin using Maven"
41+ COMMAND ${MAVEN_EXECUTABLE} clean package
42+ -B -DskipTests
43+ -Drelease=${PRELEASE}
44+ -Dthrift.version=${thrift_VERSION}
45+ DEPENDS ${THRIFTMAVENPLUGIN_SOURCES}
46+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
47+ )
48+
49+ add_custom_target (ThriftMavenPlugin ALL DEPENDS "${MAVEN_OUTPUT_JAR} " )
50+
51+ # Enable publishing from CMake if the publishing information is provided
52+ add_custom_target (ThriftMavenPluginMavenPublish
53+ COMMENT "Publishing Maven plugin to Apache Maven staging"
54+ DEPENDS ThriftMavenPlugin
55+ COMMAND ${MAVEN_EXECUTABLE} deploy
56+ -B -DskipTests
57+ -Drelease=${PRELEASE}
58+ -Dthrift.version=${thrift_VERSION}
59+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
60+ )
61+
62+ # Hook the CMake install process to the results from make ALL.
63+ # This works best when 'make all && sudo make install/fast' is used.
64+ install (FILES "${MAVEN_OUTPUT_JAR} " DESTINATION ${THRIFTMAVENPLUGIN_INSTALL_DIR} )
65+
66+ if (BUILD_TESTING)
67+ add_test (NAME ThriftMavenPluginTest
68+ COMMAND ${MAVEN_EXECUTABLE} test
69+ -B
70+ -Drelease=${PRELEASE}
71+ -Dthrift.version=${thrift_VERSION}
72+ -Dthrift.compiler=${THRIFT_COMPILER}
73+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
74+ endif ()
0 commit comments