cm: Modify maven artifact publish makefile.

  Now allows you to specify a target module to be
  compiled prior to publish via LOCAL_MAVEN_TARGET_MODULE.

  This utilizes the definition for intermediates-dir-for on
  the target module after it sets an explicit dependency from
  remote to local module.

Change-Id: I65b5e07fdcc3368e350b1935ccca381b74dce59e
diff --git a/build/core/maven_artifact_publish.mk b/build/core/maven_artifact_publish.mk
index f984473..5746f95 100644
--- a/build/core/maven_artifact_publish.mk
+++ b/build/core/maven_artifact_publish.mk
@@ -20,30 +20,34 @@
 ifeq ($(strip $(LOCAL_MAVEN_REPO)),)
   $(error LOCAL_MAVEN_REPO not defined.)
 endif
-ifeq ($(strip $(LOCAL_MAVEN_FILE_PATH)),)
-  $(error LOCAL_MAVEN_FILE_PATH not defined.)
+ifeq ($(strip $(LOCAL_MAVEN_TARGET_MODULE)),)
+  $(error LOCAL_MAVEN_TARGET_MODULE not defined.)
 endif
 ifeq ($(strip $(LOCAL_MAVEN_REPO_ID)),)
   $(error LOCAL_MAVEN_REPO_ID not defined.)
 endif
 
-
 $(full_target): pomfile := $(LOCAL_MAVEN_POM)
 $(full_target): repo := $(LOCAL_MAVEN_REPO)
-$(full_target): path_to_file := $(LOCAL_MAVEN_FILE_PATH)
+$(full_target): path_to_file := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MAVEN_TARGET_MODULE),,COMMON)/javalib.jar
 $(full_target): repoId := $(LOCAL_MAVEN_REPO_ID)
 $(full_target): classifier := $(LOCAL_MAVEN_CLASSIFIER)
 $(full_target): sources := $(LOCAL_MAVEN_SOURCES)
 $(full_target): javadoc := $(LOCAL_MAVEN_JAVADOC)
+$(full_target): artifact_path := $(LOCAL_MAVEN_ARTIFACT_PATH)
+$(full_target): artifact_path ?= $(basename $(path_to_file))
 
-$(full_target):
+$(full_target): $(LOCAL_MAVEN_TARGET_MODULE) $(path_to_file) $(artifact_path) $(ACP)
+	@echo -e ${CL_GRN}"Renaming generated sdk javalib jar"${CL_RST}
+	$(hide) $(ACP) $(path_to_file) $(artifact_path)
+	@echo -e ${CL_GRN}"Publishing to Maven"${CL_RST}
 	$(hide) mvn -e -X gpg:sign-and-deploy-file \
 		    -DpomFile=$(pomfile) \
 			-Durl=$(repo) \
-			-Dfile=$(path_to_file) \
+			-Dfile=$(artifact_path) \
 			-DrepositoryId=$(repoId) \
 			-Dclassifier=$(classifier) \
 			-Dsources=$(sources) \
 			-Djavadoc=$(javadoc)
 	@echo -e ${CL_GRN}"Publishing:"${CL_RST}" $@"
-$(LOCAL_MODULE) : $(full_target)
\ No newline at end of file
+$(LOCAL_MODULE): $(full_target)
\ No newline at end of file