{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • API Design /
avatar image
1
Question by Sean Case · Mar 23, 2016 at 08:03 PM · 404 Views java calloutjavajavacalloutjava-calloutgrunt

Problem building Java callout classes via Grunt versus directly on command line

This is our first Java callout-enabled API proxy. For our other APIs, we are using the Apigee grunt deployment tool: https://github.com/apigeecs/apigee-deploy-grunt-plugin/blob/master/Gruntfile.js

We are attempting to compile using it, so we've enabled the javac step in the file. This is the command:

javac java/src/com/<our-company>/ecommerce/<vendor-tool>/executor/*.java java/src/com/<our-company>/ecommerce/<vendor-tool>/util/*.java -d ./target/java/bin -cp /c/Git/<our-api>/java/lib/expressions-1.0.0.jar:/c/Git/<our-api>/java/lib/message-flow-1.0.0.jar -verbose

which works when running on the command line. However, when running it using Grunt, the classpath doesn't seem to get picked up and the necessary Apigee classes are coming back as not being found. Is this a discrepancy between how the Grunt shell processing works?

Here is the entry we have in Gruntfile.js:

javaCompile: {
	        	 command: 'javac java/src/com/<our-company>/ecommerce/<vendor-tool>/executor/*.java java/src/com/<our-company>/ecommerce/<vendor-tool>/util/*.java -d ./target/java/bin -cp /C/Git/<our-api>/java/lib/expressions-1.0.0.jar:/C/Git/<our-api>/java/lib/message-flow-1.0.0.jar -verbose'
	         }
Comment
Add comment Show 1
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sean Case · Mar 23, 2016 at 08:13 PM 0
Link

@Diego Zuluaga, might you have a suggestion on this one?

Close

1 Answer

  • Sort: 
avatar image
0

Answer by Sean Case · Mar 28, 2016 at 12:24 PM

Ok, I think I've found a solution. It appears that grunt-chalk (which is used by grunt-shell) is setting the terminal type based on platform. I was able to use it's line:

process.platform === 'win32' && !/^xterm/i.test(process.env.TERM)

along with a function within the grunt shell command to create a test and conditional build:

shell: {      
  options: {
     stderr: false,
     failOnError: true
  },
  javaCompile: {
     command: function () {
	        if (process.platform === 'win32') {
                  return 'javac -source 1.7 -target 1.7 java/src/com/<path to source>/*.java java/src/<path to source>/*.java -cp %cd%\java\lib\expressions-1.0.0.jar;%cd%\java\lib\message-flow-1.0.0.jar -d target/java/bin  -verbose';
	       } else {
	        	return 'javac -source 1.7 -target 1.7 java/src/com/<path to source>/*.java java/src/<path to source>/*.java -cp ${PWD}/java/lib/expressions-1.0.0.jar:${PWD}/java/lib/message-flow-1.0.0.jar -d ./target/java/bin  -verbose';
	              }
               }
     },
     javaJar : {
        command: 'jar cvf target/apiproxy/resources/java/BuildReviewURL.jar target/java/*'    }
 }

which seems to work.

I didn't have much time to investigate further, but was also hopeful that perhaps utilizing grunt-run-java (https://www.npmjs.com/package/grunt-run-java) may have been an opportunity to resolve this, too.

Thanks for the assistance!

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What version of Java is supported for Java callouts? 1 Answer

Setting header value within Java callout. 3 Answers

How does Java Callout policy update the member variables of the Java code? 1 Answer

Java Callout access to File Resources 1 Answer

Json payload java callout 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges