Skip to content

Commit

Permalink
Added a simple 'HelloWorld' java example. This can be quickly used to…
Browse files Browse the repository at this point in the history
… demonstrate different issues in pants without the complexities of the `examples/src/java/com/pants/examples/hello/main` target that is used to demonstrate more features of pants, like bundling, resources, etc.

Testing Done:
./pants run examples/src/java/com/pants/examples/hello/simple

Ran ./build-support/bin/publish_docs.sh  and looked at the first_tutorial page.

Bugs closed: 1180, 1365

Reviewed at https://rbcommons.com/s/twitter/r/2028/
  • Loading branch information
ericzundel committed Apr 3, 2015
1 parent c468085 commit 8a495cb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
8 changes: 8 additions & 0 deletions examples/src/java/com/pants/examples/hello/simple/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

jvm_binary(name = 'simple',
source = 'HelloWorld.java',
main = 'com.pants.examples.hello.simple.HelloWorld',
)

17 changes: 17 additions & 0 deletions examples/src/java/com/pants/examples/hello/simple/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).

package com.pants.examples.hello.simple;

/**
* A simple example that is runnable from within pants:
*
* ./pants run examples/src/java/com/pants/examples/hello/simple
*
*/
public class HelloWorld {

public static void main(String[] args) {
System.out.println("Hello World!");
}
}
8 changes: 7 additions & 1 deletion src/docs/first_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ will still compile them since it knows it must compile before it can
test.

:::bash
$ pants goal test src/java/com/myorg/myproject tests/java/com/myorg/myproject
$ pants test src/java/com/myorg/myproject tests/java/com/myorg/myproject

**Run a binary**<br>
Use pants to execute a binary target. Compiles the code first if it is not up to date.

:::bash
$ ./pants run examples/src/java/com/pants/examples/hello/simple

**Get Help**<br>
Get the list of goals:
Expand Down

0 comments on commit 8a495cb

Please sign in to comment.