Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# When a release branch is merged into master, builds the artifacts and creates a release.

name: Build Release

on:
pull_request:
branches:
- development

jobs:
build_artifacts:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew check
41 changes: 10 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ This will generate a manifest file named `protop.json`.
}
```

If the root of the proto files are a subdirectory (eg `src/main/proto`), add the following to `protop.json`:
```json
"root-dir": "src/main/proto"
```

This will allow clients not to have to adjust the protoc include path.

## Publish ("link") locally
This will make the project accessible to all other projects that run `sync` with links enabled.
```bash
Expand All @@ -81,12 +88,12 @@ To unlink all projects system-wide:
$ protop links clean
```

### Publish to a repository*
### Publish to a repository
```bash
$ protop publish -r=https://repository.example.com
```

*There is an implementation of a Nexus plugin for protop required for this to work. More details [here](https://github.com/protop-io/nexus-repository-protop). Coming soon, there will be better documentation on the API of the repository itself.
> There is an implementation of a Nexus plugin for protop required for this to work. More details [here](https://github.com/protop-io/nexus-repository-protop). Coming soon, there will be better documentation on the API of the repository itself.

### Sync local/external dependencies
Run the following with `-l` or `--use-links` to include local/linked dependencies, or run without it to only include dependencies from the network.
Expand Down Expand Up @@ -120,35 +127,7 @@ $ protop cache clean
## Use with Gradle or other build tools

### Use with Gradle
There isn't a custom Gradle plugin for protop (yet). Even so, the implementation is quite simple. Assuming you have an existing `build.gradle` setup for a protobuf project, add the following task to the root project:
```groovy
task protop(type: Exec) {
workingDir "."
commandLine "protop", "sync"
}
```
This task will simply run `protop sync`. To invoke it upon `gradle build` and ensure that it is run before the protos are generated, alter the `protobuf` block (or add it now):
```groovy
protobuf {
// ...
generateProtoTasks {
// ...
all().each { task -> task.dependsOn protop }
}
}
```

Finally, make sure the compiler will find all the synced protos:
```groovy
sourceSets {
main {
// ...
proto {
srcDir ".protop/path"
}
}
}
```
Use the [Gradle plugin](https://github.com/google/protobuf-gradle-plugin).

### Use with protoc directly
With dependencies already synced, you can call `protoc` in a project that looks like the one above:
Expand Down
49 changes: 24 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ plugins {
}

ext {
slf4jVersion = "1.7.28"
lombokVersion = "1.18.16"
jvmVersion = JavaVersion.VERSION_13
lombokVersion = '1.18.16'
jvmVersion = JavaVersion.VERSION_14
}

description = "Protop CLI"
Expand All @@ -29,28 +28,28 @@ java {

subprojects {
dependencies {
implementation "com.google.guava:guava:27.0.1-jre"
implementation "com.fasterxml.jackson.core:jackson-databind:2.9.9.3"
implementation "com.fasterxml.jackson.core:jackson-annotations:2.9.9"
implementation "javax.validation:validation-api:2.0.1.Final"
implementation "commons-io:commons-io:2.6"
implementation "ch.qos.logback:logback-classic:1.2.3"
implementation "io.reactivex.rxjava2:rxjava:2.2.17"

compileOnly "org.projectlombok:lombok:$lombokVersion"
compileOnly "javax.annotation:javax.annotation-api:1.3.2"

annotationProcessor "org.projectlombok:lombok:$lombokVersion"

testImplementation "junit:junit:4.12"
}
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"

tasks.withType(org.gradle.api.tasks.javadoc.Javadoc).all { enabled = false }
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
compileOnly "org.projectlombok:lombok:${lombokVersion}"

implementation 'ch.qos.logback:logback-classic:1.2.3'
implementation 'com.google.guava:guava:27.0.1-jre'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.9'
implementation 'commons-io:commons-io:2.6'
implementation 'io.reactivex.rxjava2:rxjava:2.2.17'
implementation 'javax.validation:validation-api:2.0.1.Final'

testImplementation 'org.assertj:assertj-core:3.+'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.+'
}

java {
sourceCompatibility = jvmVersion
targetCompatibility = jvmVersion
test {
useJUnitPlatform()
}

tasks.withType(org.gradle.api.tasks.javadoc.Javadoc).all { enabled = false }
}

dependencies {
Expand All @@ -73,16 +72,16 @@ task distFatJar(type: Jar) {
'Built-By' : System.properties['user.name'],
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.revision']}",
'Build-Jdk' : "${System.properties['java.version']}",
"Main-Class" : "io.protop.cli.ProtopCli"
)
}

from sourceSets.main.output

// Do the rest of this task as such because https://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
doFirst {

from configurations.runtimeClasspath.
findAll { it.name.endsWith('jar') }.
collect { zipTree(it) }
Expand Down
21 changes: 15 additions & 6 deletions protop-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ plugins {
}

dependencies {
implementation "org.apache.httpcomponents:httpclient:4.5.11"
implementation "org.apache.commons:commons-compress:1.19"
implementation "org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r"
runtimeOnly 'io.grpc:grpc-netty-shaded:1.26.0'

implementation 'org.apache.commons:commons-compress:1.19'
implementation 'org.apache.httpcomponents:httpclient:4.5.11'
implementation 'org.apache.httpcomponents:httpmime:4.5.11'
implementation 'org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r'
implementation 'org.apache.maven.artifact:maven-artifact:3.0-alpha-1' // For ComparableVersion
implementation "io.grpc:grpc-stub:1.26.0"
implementation "io.grpc:grpc-protobuf:1.26.0"
runtimeOnly "io.grpc:grpc-netty-shaded:1.26.0"
implementation 'io.grpc:grpc-stub:1.26.0'
implementation 'io.grpc:grpc-protobuf:1.26.0'

testImplementation 'org.mockito:mockito-core:3.3.3'
testImplementation 'org.mockito:mockito-junit-jupiter:3.3.3'
}

test {
environment 'TEST_DATA_DIR', "${projectDir}/src/test/data"
}

protop {
Expand Down
11 changes: 10 additions & 1 deletion protop-core/src/main/java/io/protop/core/manifest/Manifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder({"name", "org", "version", "description", "keywords", "license", "homepage"})
@JsonPropertyOrder({"name", "org", "version", "description", "root-dir", "keywords", "license", "homepage"})
public class Manifest {

private static final Logger logger = Logger.getLogger(Manifest.class);
Expand All @@ -42,6 +42,9 @@ public class Manifest {
// @JsonSerialize(converter = PathListToStringList.class)
// private List<Path> include;

@JsonProperty("root-dir")
private Path rootDir;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("dependencies")
private DependencyMap dependencies;
Expand All @@ -67,6 +70,7 @@ public class Manifest {
@JsonProperty("version") @NotNull Version version,
@JsonProperty("organization") @NotNull String organization,
// @JsonProperty("include") List<Path> include,
@JsonProperty("root-dir") @NotNull Path rootDir,
@JsonProperty("dependencies") @JsonDeserialize(converter = DependencyMapDeserializer.class)
DependencyMap dependencies,
@JsonProperty("description") String description,
Expand All @@ -78,6 +82,7 @@ public class Manifest {
this.version = version;
this.organization = organization;
// this.include = Objects.isNull(include) ? ImmutableList.of() : ImmutableList.copyOf(include);
this.rootDir = rootDir;
this.dependencies = dependencies;
this.description = description;
this.readme = readme;
Expand Down Expand Up @@ -106,4 +111,8 @@ public static Optional<Manifest> from(Path directory) {
throw new RuntimeException(message, e);
}
}

public static Optional<Manifest> from(final File directory) {
return from(directory.toPath());
}
}
36 changes: 36 additions & 0 deletions protop-core/src/main/java/io/protop/core/sync/FileWithRootDir.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.protop.core.sync;

import lombok.EqualsAndHashCode;
import lombok.Getter;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

@EqualsAndHashCode
@Getter
class FileWithRootDir {
private final Path rootDir;
private final Path target;

public FileWithRootDir(final Path rootDir, final File file) {
this(rootDir, file.toPath());
}

public FileWithRootDir(final Path rootDir, final Path target) {
this.rootDir = rootDir != null ? rootDir : Path.of("");
this.target = target;
}

public void createSymbolicLink(final Path protopPathDir, final Path linkWithRootDir) throws IOException {
final Path linkRelative = protopPathDir
.resolve(rootDir)
.relativize(linkWithRootDir);
final Path linkWithoutRootDir = protopPathDir.resolve(linkRelative);

Files.createDirectories(linkWithoutRootDir.getParent());
Files.deleteIfExists(linkWithoutRootDir);
Files.createSymbolicLink(linkWithoutRootDir, target);
}
}
Loading