From afbcdbea3f91d2d93da9816dedf659f405bb60c5 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Tue, 25 Aug 2020 12:07:41 +0200 Subject: [PATCH] v1.2.0 --- .gitignore | 1 + biz.aQute.protoc.test/.classpath | 13 +++++++++ biz.aQute.protoc.test/.gitignore | 1 + biz.aQute.protoc.test/.project | 23 +++++++++++++++ .../org.eclipse.core.resources.prefs | 2 ++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++++++ biz.aQute.protoc.test/bnd.bnd | 8 +++++ .../proto/adddressbook.proto | 29 +++++++++++++++++++ biz.aQute.protoc.test/proto/example.proto | 0 .../src-protoc/example.proto | 0 biz.aQute.protoc/.classpath | 2 +- biz.aQute.protoc/bnd.bnd | 7 +++-- .../main/java/biz/aQute/protoc/Protoc.java | 18 ++++++------ .../resources/biz/aQute/protoc/timestamp.txt | 1 + cnf/build.bnd | 2 +- cnf/central.mvn | 2 +- 16 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 biz.aQute.protoc.test/.classpath create mode 100644 biz.aQute.protoc.test/.gitignore create mode 100644 biz.aQute.protoc.test/.project create mode 100644 biz.aQute.protoc.test/.settings/org.eclipse.core.resources.prefs create mode 100644 biz.aQute.protoc.test/.settings/org.eclipse.jdt.core.prefs create mode 100644 biz.aQute.protoc.test/bnd.bnd create mode 100644 biz.aQute.protoc.test/proto/adddressbook.proto create mode 100644 biz.aQute.protoc.test/proto/example.proto create mode 100644 biz.aQute.protoc.test/src-protoc/example.proto create mode 100644 biz.aQute.protoc/src/main/resources/biz/aQute/protoc/timestamp.txt diff --git a/.gitignore b/.gitignore index b1354c9..51f4993 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ target/ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* /.metadata/ +biz.aQute.protoc.test/errors \ No newline at end of file diff --git a/biz.aQute.protoc.test/.classpath b/biz.aQute.protoc.test/.classpath new file mode 100644 index 0000000..37d980e --- /dev/null +++ b/biz.aQute.protoc.test/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/biz.aQute.protoc.test/.gitignore b/biz.aQute.protoc.test/.gitignore new file mode 100644 index 0000000..b34c537 --- /dev/null +++ b/biz.aQute.protoc.test/.gitignore @@ -0,0 +1 @@ +/src-gen/ diff --git a/biz.aQute.protoc.test/.project b/biz.aQute.protoc.test/.project new file mode 100644 index 0000000..caa2204 --- /dev/null +++ b/biz.aQute.protoc.test/.project @@ -0,0 +1,23 @@ + + + biz.aQute.protoc.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/biz.aQute.protoc.test/.settings/org.eclipse.core.resources.prefs b/biz.aQute.protoc.test/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..1554c6f --- /dev/null +++ b/biz.aQute.protoc.test/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/bnd.bnd=UTF-8 diff --git a/biz.aQute.protoc.test/.settings/org.eclipse.jdt.core.prefs b/biz.aQute.protoc.test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/biz.aQute.protoc.test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/biz.aQute.protoc.test/bnd.bnd b/biz.aQute.protoc.test/bnd.bnd new file mode 100644 index 0000000..664cb59 --- /dev/null +++ b/biz.aQute.protoc.test/bnd.bnd @@ -0,0 +1,8 @@ +src = ${^src},src-gen + +-generate \ + proto; \ + output = src-gen; \ + generate = "biz.aQute.protoc.Protoc -I=proto --java_out=src-gen proto/adddressbook.proto 2>errors" + +-buildpath: com.google.protobuf;version='4.0.0' \ No newline at end of file diff --git a/biz.aQute.protoc.test/proto/adddressbook.proto b/biz.aQute.protoc.test/proto/adddressbook.proto new file mode 100644 index 0000000..3153ad5 --- /dev/null +++ b/biz.aQute.protoc.test/proto/adddressbook.proto @@ -0,0 +1,29 @@ +syntax = "proto2"; + +package tutorial; + +option java_package = "com.example.tutorial"; +option java_outer_classname = "AddressBookProtos"; + +message Person { + required string name = 1; + required int32 id = 2; + optional string email = 3; + + enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; + } + + message PhoneNumber { + required string number = 1; + optional PhoneType type = 2 [default = HOME]; + } + + repeated PhoneNumber phones = 4; +} + +message AddressBook { + repeated Person people = 1; +} \ No newline at end of file diff --git a/biz.aQute.protoc.test/proto/example.proto b/biz.aQute.protoc.test/proto/example.proto new file mode 100644 index 0000000..e69de29 diff --git a/biz.aQute.protoc.test/src-protoc/example.proto b/biz.aQute.protoc.test/src-protoc/example.proto new file mode 100644 index 0000000..e69de29 diff --git a/biz.aQute.protoc/.classpath b/biz.aQute.protoc/.classpath index 7bea397..5691ad8 100644 --- a/biz.aQute.protoc/.classpath +++ b/biz.aQute.protoc/.classpath @@ -4,5 +4,5 @@ - + diff --git a/biz.aQute.protoc/bnd.bnd b/biz.aQute.protoc/bnd.bnd index b9d8265..eade336 100644 --- a/biz.aQute.protoc/bnd.bnd +++ b/biz.aQute.protoc/bnd.bnd @@ -1,10 +1,11 @@ --includepackage biz.aQute.protoc +-includepackage biz.aQute.protoc.* -includeresource: \ exe/protoc-osx-x86_64=${repo;com.google.protobuf:protoc:exe:osx-x86_64}, \ exe/protoc-windows-x86_64=${repo;com.google.protobuf:protoc:exe:windows-x86_64}, \ - exe/protoc-linux-x86_64=${repo;com.google.protobuf:protoc:exe:linux-x86_64} + exe/protoc-linux-x86_64=${repo;com.google.protobuf:protoc:exe:linux-x86_64},\ + {src/main/resources} -buildpath: \ @@ -15,4 +16,4 @@ Main-Class biz.aQute.protoc.Protoc JPM-Command protoc --conditionalpackage: aQute*, org.slf* \ No newline at end of file +-conditionalpackage: aQute*, org.slf* diff --git a/biz.aQute.protoc/src/main/java/biz/aQute/protoc/Protoc.java b/biz.aQute.protoc/src/main/java/biz/aQute/protoc/Protoc.java index 87bfeda..a3004c9 100644 --- a/biz.aQute.protoc/src/main/java/biz/aQute/protoc/Protoc.java +++ b/biz.aQute.protoc/src/main/java/biz/aQute/protoc/Protoc.java @@ -6,9 +6,9 @@ import java.nio.file.Files; import java.nio.file.attribute.PosixFilePermission; import java.util.EnumSet; -import java.util.jar.Manifest; import aQute.lib.io.IO; +import aQute.lib.strings.Strings; import aQute.libg.command.Command; public class Protoc { @@ -30,12 +30,12 @@ else if (osName.startsWith("mac") || osName.startsWith("darwin") || osName.start URL resource = Protoc.class.getResource(name); if (resource == null) { - throw new IllegalArgumentException("Corrupt jar, not found resource " + name); + throw new IllegalArgumentException("Corrupt jar, not found " + name); } IO.copy(resource, f); f.setLastModified(modified); Files.setPosixFilePermissions(f.toPath(), - EnumSet.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_READ)); + EnumSet.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE)); } Command cmd = new Command(); cmd.add(f.getAbsolutePath()); @@ -46,11 +46,11 @@ else if (osName.startsWith("mac") || osName.startsWith("darwin") || osName.start } private static long getModified() throws NumberFormatException, IOException { - return Long.parseLong( getManifest().getMainAttributes().getValue("Bnd-LastModified")); - } - - private static Manifest getManifest() throws IOException { - URL url = Protoc.class.getResource("/META-INF/MANIFEST.MF"); - return new Manifest(url.openStream()); + String timestamp = IO.collect(Protoc.class.getResource("timestamp.txt")); + if ( timestamp == null) { + return 0L; + } + + return Long.parseLong(Strings.trim(timestamp)); } } diff --git a/biz.aQute.protoc/src/main/resources/biz/aQute/protoc/timestamp.txt b/biz.aQute.protoc/src/main/resources/biz/aQute/protoc/timestamp.txt new file mode 100644 index 0000000..c382092 --- /dev/null +++ b/biz.aQute.protoc/src/main/resources/biz/aQute/protoc/timestamp.txt @@ -0,0 +1 @@ +${now;long} \ No newline at end of file diff --git a/cnf/build.bnd b/cnf/build.bnd index 7c2e67f..4e57778 100644 --- a/cnf/build.bnd +++ b/cnf/build.bnd @@ -21,7 +21,7 @@ test-cases: ${classes;NAMED;*Test} copyright.year = ${tstamp;yyyy} baseline.version: 1.0.0 -base.version: 1.1.0 +base.version: 1.2.0 # To release, remove the -SNAPSHOT diff --git a/cnf/central.mvn b/cnf/central.mvn index 209f4b3..a76d941 100644 --- a/cnf/central.mvn +++ b/cnf/central.mvn @@ -6,7 +6,7 @@ com.google.protobuf:protoc:exe:linux-x86_64:4.0.0-rc-2 com.google.protobuf:protoc:exe:osx-x86_64:4.0.0-rc-2 com.google.protobuf:protoc:exe:windows-x86_32:4.0.0-rc-2 com.google.protobuf:protoc:exe:windows-x86_64:4.0.0-rc-2 - +com.google.protobuf:protobuf-java:4.0.0-rc-2 # OSGi R7