Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update java repo tools #141

Merged
merged 25 commits into from
Mar 31, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
26e3280
Initial empty repository
tswast Mar 1, 2016
f8b4964
Initialize the repository.
tswast Mar 1, 2016
7d5661d
Add Travis configuration.
tswast Mar 4, 2016
750e456
Merge pull request #1 from GoogleCloudPlatform/travis
tswast Mar 4, 2016
cf3de1a
Remove unnecessary properties.
tswast Mar 4, 2016
99e2d6c
Merge pull request #2 from GoogleCloudPlatform/pom
tswast Mar 4, 2016
ac6ce48
Ignore generated AutoValue classes from checkstyle.
tswast Mar 4, 2016
8d4b9a3
Ignore JavaDoc rules in test classes.
tswast Mar 4, 2016
5c9a316
Merge pull request #3 from GoogleCloudPlatform/suppress
tswast Mar 4, 2016
344227c
Ignore service account file.
tswast Mar 17, 2016
108bbd2
Merge pull request #4 from GoogleCloudPlatform/java-repo-tools
tswast Mar 17, 2016
3c48097
Add license header to POM.
tswast Mar 17, 2016
237c693
Merge pull request #6 from GoogleCloudPlatform/license
tswast Mar 18, 2016
7c9d494
Add instructions for using with subtrees.
tswast Mar 18, 2016
bc24c2b
Merge pull request #7 from GoogleCloudPlatform/readme
tswast Mar 18, 2016
c3264a5
Remove extra newline in README
tswast Mar 29, 2016
fcbbca5
Remove another extra newline.
tswast Mar 29, 2016
2e5da26
Checkstyle fixes.
tswast Mar 29, 2016
79d5d11
Merge pull request #8 from GoogleCloudPlatform/import-order
lesv Mar 29, 2016
638b601
Remove command that was copy-paste error.
tswast Mar 30, 2016
3b96c16
Pull in updates from java-repo-tools.
tswast Mar 30, 2016
810d4a7
Update README.md
tswast Mar 30, 2016
08cbe5e
Merge branch 'master' of github.com:GoogleCloudPlatform/java-repo-too…
tswast Mar 31, 2016
d156201
Add much easier steps for pulling in changes
tswast Mar 31, 2016
3692a5d
Merge branch 'master' of github.com:GoogleCloudPlatform/java-repo-too…
tswast Mar 31, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Pull in updates from java-repo-tools.
  • Loading branch information
tswast committed Mar 30, 2016
commit 3b96c16f45d74c261512cd68e46477e8ec0f4a45
155 changes: 155 additions & 0 deletions java-repo-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,161 @@ in the [GoogleCloudPlaftorm](https://github.com/GoogleCloudPlatform)
organization.


## Using this repository

This repository is copied into a subtree of other Java repositories, such as
[java-docs-samples](/GoogleCloudPlatform/java-docs-samples). Note, that a
subtree is just the code copied into a directory, so a regular `git clone` will
continue to work.


### Adding to a new repository

To copy `java-repo-tools` into a subtree of a new repository `my-java-samples`,
first add this repository as a remote. We then fetch all the changes from this
`java-repo-tools`.

```
git remote add java-repo-tools git@github.com:GoogleCloudPlatform/java-repo-tools.git
git fetch java-repo-tools master
```

To make it easier to push changes back upstream, create a new branch.

```
git checkout -b java-repo-tools java-repo-tools/master
```

We can then go back to the `my-java-samples` code and prepare a Pull Request to
add the `java-repo-tools` code in a subtree.

```
git checkout master
# Making a new branch ia optional, but recommended to send a pull request to
# start using java-repo-tools.
git checkout -b use-java-repo-tools
git read-tree --prefix=java-repo-tools/ -u java-repo-tools
```

Now all the content of `java-repo-tools` will be in the `java-repo-tools/`
directory (which we specified in the `--prefix` command).

#### Using the Maven configuration

If all the projects within your `my-java-samples` share a common parent POM for
plugin configuration (like checkstyle). We can then make the
`java-repo-tools/pom.xml` parent of this.

```
<!-- Parent POM defines common plugins and properties. -->
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.0</version>
<relativePath>java-repo-tools</relativePath>
</parent>
```

Once this is added to the common parent, all modules will have the same plugin
configuration applied. If the children POMs provide the plugin information
themselves, it will override this configuration, so you should delete any
now-redundant plugin information.


#### Examples

- Adding to repository with an existing parent POM: Pull Request
[java-docs-samples#125][java-docs-samples-125].

[java-docs-samples-125]: https://github.com/GoogleCloudPlatform/java-docs-samples/pull/125


### Detecting if you need to synchronize a subtree

If you haven't done this before, run

```
git remote add java-repo-tools git@github.com:GoogleCloudPlatform/java-repo-tools.git
git fetch java-repo-tools master
# Optional, but it makes pushing changes upstream easier.
git checkout -b java-repo-tools java-repo-tools/master
```

To detect if you have changes in the directory, run

```
git fetch java-repo-tools
git diff-tree -p HEAD:java-repo-tools/ java-repo-tools/master
```

or to diff against your local `java-repo-tools` branch:

```
git diff-tree -p HEAD:java-repo-tools/ java-repo-tools --
```

(The trailing `--` is to say that we want to compare against the branch, not the
directory.)


### Pulling changes from Java Repository Tools to a subtree

To update the `java-repo-tools` directory, if you haven't done this before, run

```
git remote add java-repo-tools git@github.com:GoogleCloudPlatform/java-repo-tools.git
git fetch java-repo-tools master
git checkout -b java-repo-tools java-repo-tools/master
```

To pull the latest changes from this `java-repo-tools` repository, run:

```
git checkout java-repo-tools
git pull java-repo-tools master
```

Pull them into the main code.

```
git checkout master
# Making a new branch is optional, but recommended to send a pull request for
# update.
git checkout -b update-java-repo-tools
git merge --squash -Xsubtree=java-repo-tools/ --no-commit java-repo-tools
```

Then you can make any needed changes to make the rest of the repository
compatible with the updated `java-repo-tools` code, commit, push, and send a
Pull Request as you would in the normal flow.


### Pushing changes from a subtree upstream to Java Repository Tools

What if you make changes in your repository and now want to push them upstream?

Assuming you just commited changes in the `java-repo-tools/` directory of your
`my-main-branch`, to merge the changes into the local `java-repo-tools` branch,
we need to cherry pick this commit using the subtree strategy. It will ignore
any changes to file not in the `java-repo-tools/` directory.

```
git checkout java-repo-tools
git cherry-pick -x --strategy=subtree my-main-branch
```

After you have committed all the changes you want to your `java-repo-tools`
branch, you can push to the upstream `java-repo-tools` repository with the
following command. (Replace `name-for-remote-branch` with the name you'd like to
give the branch on the `java-repo-tools` repository.)

```
git push java-repo-tools java-repo-tools:name-for-remote-branch
```

Then, you can send a pull request to the `java-repo-tools` repository.


## Contributing changes

- See [CONTRIBUTING.md](CONTRIBUTING.md)
Expand Down
4 changes: 2 additions & 2 deletions java-repo-tools/google-checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@
</module>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="CustomImportOrder">
<property name="specialImportsRegExp" value="com.google"/>
<property name="specialImportsRegExp" value="^javax\."/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
<property name="customImportOrderRules" value="STATIC###SAME_PACKAGE(2)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS"/>
</module>
<module name="MethodParamPad"/>
<module name="OperatorWrap">
Expand Down