From 756f0019c3f7df0438f1ad4eb0b9c13670fd3a24 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 3 Feb 2023 02:21:20 +0100 Subject: [PATCH] [build] Uploading edge repo to cloudflare R2 bucket straight from ant now possible --- .gitignore | 4 +- buildScripts/eclipse-p2.ant.xml | 2 +- buildScripts/ivy.xml | 1 + buildScripts/mapstructBinding.ant.xml | 2 +- buildScripts/maven.ant.xml | 93 +++++++--- buildScripts/setup.ant.xml | 62 ++----- buildScripts/website.ant.xml | 8 +- .../lombok/publish/PublishToBucket.java | 159 ++++++++++++++++++ ssh.knownHosts | 2 - 9 files changed, 246 insertions(+), 87 deletions(-) create mode 100644 src/support/lombok/publish/PublishToBucket.java delete mode 100644 ssh.knownHosts diff --git a/.gitignore b/.gitignore index d4285573c8..c9dcccb544 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ /google.properties /debug /*.launch -/ssh.configuration /findbugsReport.html /lib /.settings @@ -24,4 +23,5 @@ /website/lombokSupporters /pom.xml /jvm.locations -/testenv \ No newline at end of file +/testenv +/gpg.keyring diff --git a/buildScripts/eclipse-p2.ant.xml b/buildScripts/eclipse-p2.ant.xml index 75f6c4ebd8..baf48c7a07 100644 --- a/buildScripts/eclipse-p2.ant.xml +++ b/buildScripts/eclipse-p2.ant.xml @@ -115,7 +115,7 @@ This buildfile is part of projectlombok.org. It is responsible for building the - + + diff --git a/buildScripts/mapstructBinding.ant.xml b/buildScripts/mapstructBinding.ant.xml index d7c52dc3d5..eb80dc87b9 100644 --- a/buildScripts/mapstructBinding.ant.xml +++ b/buildScripts/mapstructBinding.ant.xml @@ -96,7 +96,7 @@ exists as a separate dependency solely because it is itself dependent on both lo - + diff --git a/buildScripts/maven.ant.xml b/buildScripts/maven.ant.xml index fe64a611fd..a09e09de47 100644 --- a/buildScripts/maven.ant.xml +++ b/buildScripts/maven.ant.xml @@ -65,37 +65,61 @@ This buildfile is part of projectlombok.org. It makes maven-compatible repositor - - + + + + + Your lombok clone does not include the OSSRH deployment keys. Contact the core maintainers for these keys; + place them in ${gpg.keyrings} to continue. + + + + + + + + Your lombok clone does not include the OSSRH (sonatype maven central) password, needed to upload and deploy to maven central. Contact the core maintainers. + + + + + + - - - - - - - - + + + + + + + + + + + + + + + gpg (Gnu Privacy Guard) is not on your path, or ant property exe.gpg is not properly set. Install gpg/add it to your PATH. Alternatively, run with ant -Dexe.gpg=/loc/to/gpg to continue. + + + + + + + + + + + + + + + + The artifact has been published to staging. Now go to https://oss.sonatype.org/ and log in as Reinier, then doublecheck if all is well and 'release' it. - @@ -116,12 +140,25 @@ This buildfile is part of projectlombok.org. It makes maven-compatible repositor - mvn is not on your path and/or MAVEN_HOME is not set. Add mvn to your path or set MAVEN_HOME to continue. + + + + + + + + + + + + + + diff --git a/buildScripts/setup.ant.xml b/buildScripts/setup.ant.xml index 0531a392f4..ec363cbf4a 100644 --- a/buildScripts/setup.ant.xml +++ b/buildScripts/setup.ant.xml @@ -40,6 +40,10 @@ This buildfile is part of projectlombok.org. It sets up the build itself. + + + + @@ -60,55 +64,6 @@ This buildfile is part of projectlombok.org. It sets up the build itself. Full eclipse testing requires downloading a native SWT binding. This script knows how to download for OS = [mac, linux, or windows] and architecture = [aarch64 or x86-64]. You have something different, you unique snowflake you. Your OS: "${os.name}", Your arch: "${os.arch}". - - - - Your ssh.configuration file is corrupted; delete it and rerun this script. - - - - - - - - - - - - - - - The keyfile configured in your ${ssh.configuration.file} file does not exist. - - - - - - - - - - - - - - - - Aborted - - File ${ssh.keyfile} does not exist - - - - - - - - Your connection info has been written to ${ssh.configuration.file} and will be remembered for future invocations. - - - - @@ -371,6 +326,15 @@ This buildfile is part of projectlombok.org. It sets up the build itself. + + + + + + + + + ant needs to be at least v1.10.0 or higher to build lombok. Your version is: ${ant.version} diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml index d09e230fc2..aa0d150b44 100644 --- a/buildScripts/website.ant.xml +++ b/buildScripts/website.ant.xml @@ -136,7 +136,7 @@ such as applying the templates to produce the website, converting the changelog - + File dist/javadoc.tar.bz2 is available - + - + - + creds) + .build(); + + ListObjectsV2Response objList = s3.listObjectsV2(ListObjectsV2Request.builder() + .bucket(bucketName) + .prefix(bucketDir + "/") + .build()); + + Set inBucketBeforeUpload = new HashSet(); + for (S3Object obj : objList.contents()) inBucketBeforeUpload.add(obj.key()); + + dbg("Already in bucket:\n" + + inBucketBeforeUpload.stream().map(x -> " " + x + "\n").collect(Collectors.joining()) + + (inBucketBeforeUpload.isEmpty() ? " (Nothing)\n" : "")); + + try { + go0(s3, inBucketBeforeUpload, bucketDir + "/", Paths.get(rootPath)); + } catch (IOException e) { + throw new AppException("I/O exception uploading: " + e.getClass() + ": " + e.getMessage()); + } + + if (delete) { + dbg("Uploads complete. Files to delete:\n" + + inBucketBeforeUpload.stream().map(x -> " " + x + "\n").collect(Collectors.joining()) + + (inBucketBeforeUpload.isEmpty() ? " (Nothing)\n" : "")); + + if (!inBucketBeforeUpload.isEmpty()) { + List objsToDelete = new ArrayList(); + for (String key : inBucketBeforeUpload) { + objsToDelete.add(ObjectIdentifier.builder().key(key).build()); + } + s3.deleteObjects(DeleteObjectsRequest.builder() + .bucket(bucketName) + .delete(Delete.builder().objects(objsToDelete).build()) + .build()); + dbg("Deletion completed"); + } + } + } + + private static void dbg(String msg) { + if (DEBUG) System.out.println(msg); + } + + private void go0(S3Client s3, Set inBucketBeforeUpload, String prefix, Path tgt) throws IOException { + try (DirectoryStream ds = Files.newDirectoryStream(tgt)) { + for (Path child : ds) { + if (Files.isDirectory(child)) { + go0(s3, inBucketBeforeUpload, prefix + child.getFileName().toString() + "/", child); + continue; + } + + String key = prefix + child.getFileName().toString(); + PutObjectRequest req = PutObjectRequest.builder() + .bucket(bucketName) + .key(key) + .build(); + s3.putObject(req, child); + boolean overwrote = inBucketBeforeUpload.remove(key); + dbg("Uploaded: " + key + (overwrote ? " (overwrote)" : "")); + } + } + } + + private static final String LINE_DESCRIPTIONS = "accessKey/secretKey/endpoint/bucket"; + private void readCreds(Path path) throws AppException { + try { + List lines = Files.readAllLines(path); + String accessKey = null, secretKey = null, endPoint = null, bucketName = null; + for (String line : lines) { + int idx = line.indexOf('#'); + if (idx != -1) line = line.substring(0, idx); + line = line.trim(); + if (line.isEmpty()) continue; + if (accessKey == null) { accessKey = line; continue; } + if (secretKey == null) { secretKey = line; continue; } + if (endPoint == null) { endPoint = line; continue; } + if (bucketName == null) { bucketName = line; continue; } + throw new AppException("Too many lines in " + path.toAbsolutePath() + " - only 4 expected: " + LINE_DESCRIPTIONS); + } + if (bucketName == null) throw new AppException("Expected 3 lines in " + path.toAbsolutePath() + ": " + LINE_DESCRIPTIONS); + creds = AwsBasicCredentials.create(accessKey, secretKey); + endpoint = URI.create(endPoint); + this.bucketName = bucketName; + } catch (NoSuchFileException e) { + throw new AppException("File with bucket endpoint + credentials is not available. Make file " + path.toAbsolutePath() + "; it should contain something like: \n" + + "123456789abcdef0123456789abcdef0 # this is the access key\n" + + "123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0 # this is the secret\n" + + "https://12345.r2.cloudflarestorage.com # this is the endpoint\n" + + "lombok-data # this is the bucket name"); + } catch (IOException e) { + throw new AppException("I/O issue reading creds file " + path.toAbsolutePath() + ": " + e.getClass() + ": " + e.getMessage()); + } + } +} diff --git a/ssh.knownHosts b/ssh.knownHosts deleted file mode 100644 index 6cce7f0189..0000000000 --- a/ssh.knownHosts +++ /dev/null @@ -1,2 +0,0 @@ -projectlombok.org:22:ECDSA:X.509:MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wRAQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLBEEEaxfR8uEsQkf4vOblY6RA8ncDfYEt6zOg9KE5RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8AAAAA//////////+85vqtpxeehPO5ysL8YyVRAgEBA0IABKwMbAFQuRwz9+PnuBOlc1OqPAYVhg0VBTGQ1G5V6JVfb0CU5GH4NEFp+jEAoGCZNrghB0XLB3d3egfF06ihDgE= -projectlombok.org:22:EdDSA:X.509:MCowBQYDK2VwAyEA450nCMycc70u7i0qetTrh9yl6+cOS6v4y8clPCnSIHs=