Skip to content

Instantly share code, notes, and snippets.

@mz0
Last active February 23, 2023 21:16
Show Gist options
  • Save mz0/f6cf0b3b205931a0ef97295c0c1758e2 to your computer and use it in GitHub Desktop.
Save mz0/f6cf0b3b205931a0ef97295c0c1758e2 to your computer and use it in GitHub Desktop.
Shsha Windows development

Install Java

We are turning off PATH, JAVA_HOME modifications so we can install multiple versions of Java, and set PATH as needed per-project. However

  • we do not provide instructions for this scenario (TODO jps)
  • if this is the only Java on your workstation, you can let setup do these changes for you
winget install --interactive BellSoft.LibericaJDK.11

Interactively set this location C:\JDK\11, and turn off PATH, JAVA_HOME, and Jar assotiation

Setup JDK11

console output

Found Liberica JDK 11 [BellSoft.LibericaJDK.11] Version ...
Downloading https://download.bell-sw.com/java/11.0.18+10/bellsoft-jdk11.0.18+10-windows-amd64.msi
  ██████████████████████████████  ... MB / 183 MB
...

Note: flag --location "C:\JDK\11" has nearly zero effect, this empty dir is created, installition path is not changed

Install Git

winget install --interactive --id Git.Git

Found Git [Git.Git] Version 2.39.1
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/git-for-windows/git/releases/download/v2.39.1.windows.1/Git-2.39.1-64-bit.exe
  ██████████████████████████████  50.5 MB / 50.5 MB
  Successfully verified installer hash

TODO Install MySQL 5.7, 8.0, mysqldump 8.0

  • download and install mysql-installer-web-community-8.0.32.0.msi (2,506,752 Bytes)
  • select Server 8.0.32 , Server 5.7.41, Workbench MySQL-Select-Features
  • use Right Arrow button to add selected options MySQL-use-Right-Left-Arrows
  • set paths (official manual page) MySQL-Server-Data-Paths
  • install
  • configure
    • Server 8.0 - use Strong Password Encryption
    • disable binary log, chage names to distinguish between versions, lower slow log threshold

Install PostgreSQL 14

winget show PostgreSQL.PostgreSQL
Found PostgreSQL 14 [PostgreSQL.PostgreSQL]
Version: 14.5
Publisher: PostgreSQL Global Development Group
...
Installer:
  Installer Url: https://get.enterprisedb.com/postgresql/postgresql-14.5-1-windows-x64.exe
  Installer SHA256: e91b3aa882a0af54fda36043f492252e472c878904e2c3d92e6c799c33e75dea

winget install --version 14.5 --interactive PostgreSQL.PostgreSQL

  Downloading https://get.enterprisedb.com/postgresql/postgresql-14.5-1-windows-x64.exe
    ███████▊                        81.0 MB /  313 MB

!!! IMPORTANT !!! Set and save superuser 'postgres' password

TODO adjust PATH, (option) JAVA_HOME

JAVA_HOME may help when Gradle task was interrupted. TODO set it <shsha>\gradlew.bat

Create PostgreSQL user 'shsha'

chcp 1252

Avoids

WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.

have user postgres password ready, and run:

psql -U postgres
postgres=# CREATE USER shsha WITH PASSWORD '999' CREATEDB;

Configure IDEA JDK and Gradle

  • in case Gradle is set up as above IDEA-Gradle7 3

  • in case no Gradle is set up - selet 'wrapper' task in Gradle build script IDEA-Gradle-from-wrapper-task

@mz0
Copy link
Author

mz0 commented Feb 7, 2023

Gradle stuff

configurations {
  //declaring new configuration that will be used to associate with artifacts
  schema
}

task schemaJar(type: Jar) {
  //some imaginary task that creates a jar artifact with some schema
}

//associating the task that produces the artifact with the configuration
artifacts {
  //configuration name and the task:
  schema schemaJar
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.version == 'default') {
            def version = findDefaultVersionInCatalog(details.requested.group, details.requested.name)
            details.useVersion version.version
            details.because version.because
        }
    }
}

def findDefaultVersionInCatalog(String group, String name) {
    //some custom logic that resolves the default version into a specific version
    [version: "1.0", because: 'tested by QA']
}
configurations {
    instrumentedJars {
        canBeConsumed = true
        canBeResolved = false
        // If you want this configuration to share the same dependencies, otherwise omit this line
        extendsFrom implementation, runtimeOnly
    }
}

artifacts {
    instrumentedJars(instrumentedJar)
}

@mz0
Copy link
Author

mz0 commented Feb 9, 2023

https://github.com/google/auto/tree/main/service
https://search.maven.org/artifact/com.google.auto.service/auto-service
com.google.auto.service:auto-service:1.0.1
2021-11-03 https://github.com/google/auto/releases/tag/auto-service-1.0.1

import com.google.auto.service.AutoService;

@AutoService(SimpleService.class)
public class SimpleServiceImpl implements SimpleService {
    public String echo(final String value) {
        return value;
    }
}

In the implementation we “register” an instance of the service with the annotation @AutoService. This is only needed at compile time as the annotation is used by a javac annotation processor to automatically generate the service registration file:
META-INF/services/io.github.efenglu.serviceLoader.example.SimpleService
The file contains a list of Classes that implement the service:
io.github.efenglu.serviceLoader.example.SimpleServiceImpl
The implementation classes MUST have a no-arg constructor.

Erik Englund 2019-04-04 ServiceLoader: The Built in DI Framework ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment