Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from web3j/remove-plugin
Browse files Browse the repository at this point in the history
Remove plugin code and config as moving plugin code to web3j-deployer-plugin
  • Loading branch information
AlexandrouR authored Nov 1, 2021
2 parents 0682b9c + 283d1e1 commit c76ff82
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 108 deletions.
67 changes: 37 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,82 @@ A simple and lightweight library for managing deployments of Ethereum contracts

Library is intended used by the Web3j CLI, but may also be used on its own.

Through the use of two annotations, `@Predeploy` and `@Deployable`, developers can define deploy configurations and deployment methods.
Through the use of two annotations, `@Predeploy` and `@Deployable`, developers can define deploy configurations and
deployment methods.

Let's start by looking at `@Predeploy` and how this is used to define a Deployer instance for a given network

```java
package com.example.deployers

@Predeploy(profile = "my-deploy-profile")
public Deployer deployMyContract() {
Credentials credentials = ...;
public Deployer deployMyContract(){
Credentials credentials=...;

Web3j web3j = Web3j.build(...);
Web3j web3j=Web3j.build(...);

return new Deployer(web3j, new FastRawTransactionManager(web3j, credentials), new DefaultGasProvider(), "my-deploy-profile");
}
return new Deployer(web3j,new FastRawTransactionManager(web3j,credentials),new DefaultGasProvider(),"my-deploy-profile");
}
```

The profile name can be defined to whatever makes sense to you. Here we use `my-deploy-profile` as an example label.

Assuming you defined this within a package called `com.example.deployers`, you could obtain a reference to this deployer using the `DeployTools`:
Assuming you defined this within a package called `com.example.deployers`, you could obtain a reference to this deployer
using the `DeployTools`:

```java
String profile = "my-deploy-profile";
String pkgFilter = "com.example"
Deployer deployer = new DeployTools().findDeployer(profile, pkgFilter);
String profile="my-deploy-profile";
String pkgFilter="com.example"
Deployer deployer=new DeployTools().findDeployer(profile,pkgFilter);
```

Next you want to define methods that allows you to use the deployer. Often, for complex contract setups, you have multiple steps during a deployment process. Using the `@Deployable` annotation you can define the order you want them to execute, starting low:
Next you want to define methods that allows you to use the deployer. Often, for complex contract setups, you have
multiple steps during a deployment process. Using the `@Deployable` annotation you can define the order you want them to
execute, starting low:

```java
package com.example.deploy

@Deployable(order = 1)
public void deployA(Deployer deployer) {
...
}
public void deployA(Deployer deployer){
...
}

@Deployable(order = 2)
public void deployB(Deployer deployer) {
...
}
public void deployB(Deployer deployer){
...
}

@Deployable(order = 3)
public void deployC(Deployer deployer) {
...
}
public void deployC(Deployer deployer){
...
}
```

When using `runDeployer` from `DeployTools`, it will execute these as `deployA`, `deployB`, and finally `deployC` due to the `order` value on each of the `@Deployable` annotations. Execute them like so:
When using `runDeployer` from `DeployTools`, it will execute these as `deployA`, `deployB`, and finally `deployC` due to
the `order` value on each of the `@Deployable` annotations. Execute them like so:

```java
public static void main(String... args) {
String profile = "my-deploy-profile";
String pkgFilter = "com.example";
DeployTools deployTools = new DeployTools()
Deployer deployer = deployTools.findDeployer(network, pkgFilter);
deployTools.runDeployer(deployer, pkgFilter);
}
public static void main(String...args){
String profile="my-deploy-profile";
String pkgFilter="com.example";
DeployTools deployTools=new DeployTools()
Deployer deployer=deployTools.findDeployer(network,pkgFilter);
deployTools.runDeployer(deployer,pkgFilter);
}
```

## Gradle deploy task

If you include this library in your project, and also include it as a plugin, you can use the deploy task to deploy your contracts like so:
If you include the [web3j-deployer-plugin](https://github.com/web3j/web3j-deployer-plugin) in your project as a plugin,
you can use the deploy task to deploy your contracts like so:

```bash
./gradlew deploy -Pprofile=my-profile -Ppackage=org.testing
```

To add this as a plugin to your gradle project, in build.gradle include, the below replaing x.y.z with the current version:
To add this as a plugin to your gradle project, in build.gradle include, the below replaing x.y.z with the current
version:

```gradle
plugins {
Expand Down
26 changes: 1 addition & 25 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
plugins {
id 'java-gradle-plugin'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'de.marcphilipp.nexus-publish' version '0.4.0'
id 'io.codearte.nexus-staging' version '0.22.0'
id 'com.gradle.plugin-publish' version '0.12.0'
}

apply from: "$rootDir/gradle/publish/build.gradle"
apply plugin: 'java'
apply plugin: 'idea'


description 'Library for managing deployments of Ethereum contracts and transactions.'


gradlePlugin {
plugins {
deploy {
id = 'org.web3j.deploy'
implementationClass = 'org.web3j.deploy.DeployPlugin'
}
}
}


pluginBundle {
website = 'https://web3j.io/'
vcsUrl = 'https://github.com/web3j/web3j-deployer'
description = 'Gradle plugin for managing deployments of Ethereum contracts and transactions.'
tags = [
'ethereum',
'web3j',
'deployer'
]
}

group 'org.web3j'
version '4.8.8'

Expand Down
53 changes: 0 additions & 53 deletions src/main/kotlin/org/web3j/deploy/DeployPlugin.kt

This file was deleted.

0 comments on commit c76ff82

Please sign in to comment.