Skip to content
Merged
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.gradle/
/bin/
/build-export.gradle
/gradle.properties
/.classpath
/secring.gpg
Expand Down
30 changes: 19 additions & 11 deletions DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Prerequisites

- Use JDK 21 for publishing tasks.
- `build-export.gradle` is the publishing build file.
- Publishing is configured in the tracked `build.gradle`.
- Signing can come from `gradle.properties` or environment variables.
- Central credentials can come from either:
- `centralUsername` and `centralPassword`
Expand Down Expand Up @@ -36,12 +36,12 @@ scripts/release-preflight.sh

## Dry Runs

Run dry runs first to validate task wiring and credentials without uploading artifacts:
Run a dry run first to validate local publication task wiring without uploading artifacts.
Use `scripts/release-preflight.sh` above to validate required release credentials:

```bash
source scripts/load-maven-env.sh
./gradlew -b build-export.gradle --no-daemon -PcentralUsername="$CENTRAL_PORTAL_USERNAME" -PcentralPassword="$CENTRAL_PORTAL_PASSWORD" publishAggregationToCentralPortal --dry-run --console=plain
./gradlew -b build-export.gradle --no-daemon -PcentralUsername="$CENTRAL_PORTAL_USERNAME" -PcentralPassword="$CENTRAL_PORTAL_PASSWORD" publishAggregationToCentralSnapshots --dry-run --console=plain
./gradlew --no-daemon publishToMavenLocal --dry-run --console=plain
```

## Test Matrix
Expand Down Expand Up @@ -80,42 +80,50 @@ source scripts/load-maven-env.sh

```bash
source scripts/load-maven-env.sh
./gradlew -b build-export.gradle --no-daemon -PcentralUsername="$CENTRAL_PORTAL_USERNAME" -PcentralPassword="$CENTRAL_PORTAL_PASSWORD" publishToMavenLocal --console=plain
./gradlew --no-daemon publishToMavenLocal --console=plain
```

Artifacts are published under:

```bash
~/.m2/repository/org/ic4j/ic4j-codegen/0.8.0
~/.m2/repository/org/ic4j/ic4j-codegen/0.8.5
```

## Central Portal Release

```bash
source scripts/load-maven-env.sh
scripts/release-preflight.sh
./gradlew -b build-export.gradle --no-daemon -PcentralUsername="$CENTRAL_PORTAL_USERNAME" -PcentralPassword="$CENTRAL_PORTAL_PASSWORD" publishAggregationToCentralPortal --console=plain
./gradlew --no-daemon \
-PreleaseRepositoryUrl="<Maven-compatible-release-repository>" \
-PreleaseRepositoryUsername="$CENTRAL_PORTAL_USERNAME" \
-PreleaseRepositoryPassword="$CENTRAL_PORTAL_PASSWORD" \
publishMavenJavaPublicationToReleaseRepository --console=plain
```

## Central Snapshots

```bash
source scripts/load-maven-env.sh
./gradlew -b build-export.gradle --no-daemon -PcentralUsername="$CENTRAL_PORTAL_USERNAME" -PcentralPassword="$CENTRAL_PORTAL_PASSWORD" publishAggregationToCentralSnapshots --console=plain
./gradlew --no-daemon \
-PreleaseRepositoryUrl="<Maven-compatible-snapshot-repository>" \
-PreleaseRepositoryUsername="$CENTRAL_PORTAL_USERNAME" \
-PreleaseRepositoryPassword="$CENTRAL_PORTAL_PASSWORD" \
publishMavenJavaPublicationToReleaseRepository --console=plain
```

## Useful Checks

```bash
./gradlew -b build-export.gradle tasks --console=plain
./gradlew -b build-export.gradle publishToMavenLocal --info
./gradlew tasks --console=plain
./gradlew publishToMavenLocal --info
```

Release checklist for 0.8.0 and later:

1. Run `./gradlew clean test` on JDK 8.
2. Run `./gradlew clean test` on JDK 11.
3. Run `source scripts/load-maven-env.sh && ./gradlew cleanTest test` on JDK 21.
4. Run `source scripts/load-maven-env.sh && ./gradlew -b build-export.gradle -PcentralUsername="$CENTRAL_PORTAL_USERNAME" -PcentralPassword="$CENTRAL_PORTAL_PASSWORD" publishToMavenLocal` on JDK 21.
4. Run `source scripts/load-maven-env.sh && ./gradlew publishToMavenLocal` on JDK 21.
5. Run `source scripts/load-maven-env.sh && scripts/release-preflight.sh`.
6. Publish only after the JDK 8, 11, and 21 validation steps all pass.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ Java library and CLI to generate Internet Computer artifacts.

To add IC4J Codegen to your Java project, use Maven Central.

<a href="https://search.maven.org/artifact/org.ic4j/ic4j-codegen/0.8.0/jar">
https://search.maven.org/artifact/org.ic4j/ic4j-codegen/0.8.0/jar
<a href="https://search.maven.org/artifact/org.ic4j/ic4j-codegen/0.8.5/jar">
https://search.maven.org/artifact/org.ic4j/ic4j-codegen/0.8.5/jar
</a>

```xml
<dependency>
<groupId>org.ic4j</groupId>
<artifactId>ic4j-codegen</artifactId>
<version>0.8.0</version>
<version>0.8.5</version>
</dependency>
```

```gradle
implementation 'org.ic4j:ic4j-codegen:0.8.0'
implementation 'org.ic4j:ic4j-codegen:0.8.5'
```

## Build
Expand Down
131 changes: 118 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@
*/

plugins {
id 'java'
id 'java-library'
id 'eclipse'
id 'maven-publish'
id 'signing'
}



group 'org.ic4j'
version '0.8.0'
version '0.8.5'

sourceCompatibility = 1.8
targetCompatibility = 1.8

java {
withSourcesJar()
withJavadocJar()
}

tasks.withType(JavaCompile).configureEach {
if (JavaVersion.current().isJava9Compatible()) {
options.release = 8
Expand All @@ -41,15 +49,28 @@ jar {
archiveBaseName = 'ic4j-codegen'
}

configurations {
fatJarCompileOnly {
canBeConsumed = false
canBeResolved = true
extendsFrom compileOnly
}
}

task fatJar(type: Jar) {
manifest {
attributes('Implementation-Title': 'ic4j-codegen',
'Implementation-Version': project.version, 'Main-Class': 'org.ic4j.codegen.IC4J')
}

archiveBaseName = 'ic4j-codegen-with-dependencies'

from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA'
from {
(configurations.runtimeClasspath + configurations.fatJarCompileOnly)
.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}

Expand All @@ -64,10 +85,10 @@ dependencies {
compileOnly name: 'android-31'
compileOnly name: 'react-android-0.71.11'

implementation group: 'org.ic4j', name: 'ic4j-reactnative', version: '0.8.0'
implementation group: 'org.ic4j', name: 'ic4j-agent', version: '0.8.0'
implementation group: 'org.ic4j', name: 'ic4j-candid', version: '0.8.1'
implementation group: 'org.ic4j', name: 'ic4j-spring', version: '0.8.0'
api group: 'org.ic4j', name: 'ic4j-reactnative', version: '0.8.0'
api group: 'org.ic4j', name: 'ic4j-agent', version: '0.8.5'
api group: 'org.ic4j', name: 'ic4j-candid', version: '0.8.5'
api group: 'org.ic4j', name: 'ic4j-spring', version: '0.8.0'

// https://mvnrepository.com/artifact/commons-codec/commons-codec
implementation group: 'commons-codec', name: 'commons-codec', version: '1.21.0'
Expand All @@ -76,22 +97,23 @@ dependencies {
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.20.0'

// https://mvnrepository.com/artifact/org.springframework/spring-context
implementation group: 'org.springframework', name: 'spring-context', version: '5.3.39'
api group: 'org.springframework', name: 'spring-context', version: '5.3.39'

// https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api
implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: '3.0.0'
// Spring 5 generated services use javax.annotation.PostConstruct.
api group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'

// JAXB dependencies
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'

// https://mvnrepository.com/artifact/com.squareup/javapoet
implementation group: 'com.squareup', name: 'javapoet', version: '1.13.0'
api group: 'com.squareup', name: 'javapoet', version: '1.13.0'

// https://mvnrepository.com/artifact/org.apache.ws.xmlschema/xmlschema-core
implementation group: 'org.apache.ws.xmlschema', name: 'xmlschema-core', version: '2.3.2'

// https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17'
runtimeOnly group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17'

// https://mvnrepository.com/artifact/info.picocli/picocli
implementation group: 'info.picocli', name: 'picocli', version: '4.7.7'
Expand All @@ -117,3 +139,86 @@ dependencies {

}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = 'IC4J Codegen'
description = 'Java and React Native code generators for Internet Computer Candid services.'
url = 'https://github.com/ic4j/ic4j-codegen'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'ic4j'
name = 'IC4J contributors'
}
}
scm {
connection = 'scm:git:https://github.com/ic4j/ic4j-codegen.git'
developerConnection = 'scm:git:ssh://git@github.com/ic4j/ic4j-codegen.git'
url = 'https://github.com/ic4j/ic4j-codegen'
}
}
}
}
repositories {
if (providers.gradleProperty('releaseRepositoryUrl').isPresent()) {
maven {
name = 'release'
url = uri(providers.gradleProperty('releaseRepositoryUrl').get())
credentials {
username = providers.gradleProperty('releaseRepositoryUsername')
.orElse(providers.environmentVariable('CENTRAL_PORTAL_USERNAME')).getOrElse('')
password = providers.gradleProperty('releaseRepositoryPassword')
.orElse(providers.environmentVariable('CENTRAL_PORTAL_PASSWORD')).getOrElse('')
}
}
}
}
}

signing {
def signingKey = providers.environmentVariable('SIGNING_KEY').orNull
def signingPassword = providers.environmentVariable('SIGNING_PASSWORD').orNull
if (signingKey)
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
required {
gradle.taskGraph.allTasks.any {
it.name.startsWith('publish') && it.name.endsWith('Repository') && !it.name.contains('MavenLocal')
}
}
}

tasks.withType(Sign).configureEach {
onlyIf {
gradle.taskGraph.allTasks.any {
it.name.startsWith('publish') && it.name.endsWith('Repository') && !it.name.contains('MavenLocal')
}
}
}

def generatedTestSourcesDir = layout.buildDirectory.dir('generated/test-sources')

test {
outputs.dir generatedTestSourcesDir
}

tasks.register('compileGeneratedTestSources', JavaCompile) {
dependsOn test
source fileTree(generatedTestSourcesDir) {
include '**/*.java'
}
classpath = sourceSets.test.runtimeClasspath
destinationDirectory = layout.buildDirectory.dir('classes/java/generatedTest')
if (JavaVersion.current().isJava9Compatible())
options.release = 8
}

check.dependsOn tasks.named('compileGeneratedTestSources')
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
14 changes: 7 additions & 7 deletions jbang/IC4JJBang.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

//JAVA 11+
//REPOS mavencentral
//DEPS org.ic4j:ic4j-codegen:0.7.1
//DEPS org.ic4j:ic4j-agent:0.7.1
//DEPS org.ic4j:ic4j-reactnative:0.7.1
//DEPS org.ic4j:ic4j-spring:0.7.1.1
//DEPS org.ic4j:ic4j-candid:0.7.1
//DEPS org.slf4j:slf4j-simple:2.0.13
//DEPS org.ic4j:ic4j-codegen:0.8.5
//DEPS org.ic4j:ic4j-agent:0.8.5
//DEPS org.ic4j:ic4j-reactnative:0.8.0
//DEPS org.ic4j:ic4j-spring:0.8.0
//DEPS org.ic4j:ic4j-candid:0.8.5
//DEPS org.slf4j:slf4j-simple:2.0.17
//DEPS com.squareup:javapoet:1.13.0
//DEPS info.picocli:picocli:4.7.6
//DEPS info.picocli:picocli:4.7.7

/**
* Main to run IC4JJBang
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/ic4j/codegen/CodegenException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ public CodegenException(String message)
super(message);
}

public CodegenException(String message, Throwable cause)
{
super(message, cause);
}
}
Loading