Ejemplo n.º 1
0
 public JavaJar(IMatch match, ITarget target, Map<String, IExpression> parameters) {
   super(match, target, parameters);
   IExpression name = getParameter(NAME);
   if (!(name instanceof Literal)) {
     mMatch.error("JavaJar function expects a String name");
   }
   mName = name.resolve();
   mSource = getParameter(SOURCE);
   mMainClass = getParameter(MAIN_CLASS);
   mOutput = String.format("%s/%s.jar", JAR_OUTPUT, mName);
   mIntermediate = String.format("%s/%s", CLASS_OUTPUT, mName);
   mManifest = String.format("%s/MANIFEST.MF", mIntermediate);
 }
Ejemplo n.º 2
0
 /** {@inheritDoc} */
 @Override
 public void configure() {
   mMatch.addFile(mManifest);
   mMatch.addFile(mOutput);
   mMatch.setProperty(mName, mOutput);
   mSource.configure();
 }
Ejemplo n.º 3
0
 /** {@inheritDoc} */
 @Override
 public String resolve() {
   String directories = String.format("{%s,%s}", mIntermediate, JAR_OUTPUT);
   List<String> libraries = new ArrayList<>();
   String javacClasspath = "";
   String jarClasspath = "";
   if (hasParameter(LIBRARY)) {
     for (String library : getParameter(LIBRARY).resolveList()) {
       String path = mMatch.getProperty(library);
       mMatch.awaitFile(path);
       libraries.add(path);
     }
     javacClasspath = String.format("-cp %s", Utilities.join(":", libraries));
     jarClasspath = String.format("Class-Path: %s\n", Utilities.join(":", libraries));
   }
   String files = Utilities.join(" ", mSource.resolveList());
   mMatch.runCommand(String.format(MKDIR_COMMAND, directories));
   mMatch.runCommand(String.format(ECHO_COMMAND, mMainClass.resolve(), jarClasspath, mManifest));
   mMatch.runCommand(String.format(JAVAC_COMMAND, javacClasspath, files, mIntermediate));
   mMatch.runCommand(String.format(JAR_COMMAND, mOutput, mManifest, mIntermediate));
   mMatch.provideFile(mOutput);
   return mOutput;
 }