Skip to content

Commit 064dbbf

Browse files
committed
U now plugin is built and deployed with gradle
1 parent 484ddca commit 064dbbf

10 files changed

+507
-229
lines changed

.classpath

+9-29
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="src" output="target/classes" path="src/main/java">
3+
<classpathentry kind="src" output="bin/main" path="src/main/java">
44
<attributes>
5-
<attribute name="optional" value="true"/>
6-
<attribute name="maven.pomderived" value="true"/>
7-
</attributes>
8-
</classpathentry>
9-
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10-
<attributes>
11-
<attribute name="maven.pomderived" value="true"/>
5+
<attribute name="gradle_scope" value="main"/>
6+
<attribute name="gradle_used_by_scope" value="main,test"/>
127
</attributes>
138
</classpathentry>
14-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
9+
<classpathentry kind="src" output="bin/main" path="src/main/resources">
1510
<attributes>
16-
<attribute name="maven.pomderived" value="true"/>
17-
</attributes>
18-
</classpathentry>
19-
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
20-
<attributes>
21-
<attribute name="maven.pomderived" value="true"/>
11+
<attribute name="gradle_scope" value="main"/>
12+
<attribute name="gradle_used_by_scope" value="main,test"/>
2213
</attributes>
2314
</classpathentry>
15+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
16+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
2417
<classpathentry kind="src" path="target/generated-sources/annotations">
2518
<attributes>
2619
<attribute name="optional" value="true"/>
2720
</attributes>
2821
</classpathentry>
29-
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
30-
<attributes>
31-
<attribute name="optional" value="true"/>
32-
<attribute name="maven.pomderived" value="true"/>
33-
<attribute name="test" value="true"/>
34-
</attributes>
35-
</classpathentry>
36-
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
37-
<attributes>
38-
<attribute name="optional" value="true"/>
39-
<attribute name="test" value="true"/>
40-
</attributes>
41-
</classpathentry>
42-
<classpathentry kind="output" path="target/classes"/>
22+
<classpathentry kind="output" path="bin/default"/>
4323
</classpath>

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/bin/
2-
/target/
2+
/target/
3+
/build/
4+
/.gradle/
5+
/gradle/
36
release.properties
47
pom.xml.releaseBackup

.project

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>JavaPackager</name>
3+
<name>javapackager</name>
44
<comment></comment>
55
<projects>
66
</projects>
@@ -11,13 +11,13 @@
1111
</arguments>
1212
</buildCommand>
1313
<buildCommand>
14-
<name>org.eclipse.m2e.core.maven2Builder</name>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
1515
<arguments>
1616
</arguments>
1717
</buildCommand>
1818
</buildSpec>
1919
<natures>
2020
<nature>org.eclipse.jdt.core.javanature</nature>
21-
<nature>org.eclipse.m2e.core.maven2Nature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
2222
</natures>
2323
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=
2+
eclipse.preferences.version=1

README.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Add the following `plugin` tag to your `pom.xml`:
1616
<plugin>
1717
<groupId>io.github.fvarrui</groupId>
1818
<artifactId>javapackager</artifactId>
19-
<version>1.0.3|1.0.4-SNAPSHOT</version>
19+
<version>1.1.0|1.1.1-SNAPSHOT</version>
2020
<executions>
2121
<execution>
2222
<phase>package</phase>
@@ -72,7 +72,7 @@ And by default it will generate next artifacts in `target ` folder:
7272
| `${name}-${version}-${platform}.tar` | Tarball containing generated directory `${name}`. |
7373
| `${name}-${version}-${platform}.tar.gz` | Compressed tarball containing generated directory `${name}`. |
7474

75-
> :warning: DEB, RPM, EXE installer and DMG files generation will be ommited if target platform is different from current platform (see `platform` property).
75+
> :warning: Installers generation will be ommited if target platform is different from current platform (see `platform` property).
7676
7777
### Plugin configutation properties
7878

@@ -147,14 +147,14 @@ ${assetsDir}/
147147
└── ${name}.ico # on Windows it has to be a ICO file
148148
```
149149

150-
> :warning: If `iconFile` plugin property is not specified and it can't find the correct icon in `assets` folder, it will use an [icon by default](https://raw.githubusercontent.com/fvarrui/JavaPackager/master/src/main/resources/linux/default-icon.png) for all platforms.
150+
> :warning: If `iconFile` plugin property is not specified and it can't find the correct icon in `${assetsDir}` folder, it will use an [icon by default](https://raw.githubusercontent.com/fvarrui/JavaPackager/master/src/main/resources/linux/default-icon.png) for all platforms.
151151
>
152152
153153
#### Velocity templates
154154

155155
[Velocity](https://velocity.apache.org/engine/2.0/user-guide.html) templates (.vtl files) are used to generate some artifacts which have to be bundled with the app.
156156

157-
It is possible to use your own customized templates. You just have to put one of the following templates in the `assets` folder organized by platform, and the plugin will use these templates instead of default ones:
157+
It is possible to use your own customized templates. You just have to put one of the following templates in the `${assetsDir}` folder organized by platform, and the plugin will use these templates instead of default ones:
158158

159159
```
160160
${assetsDir}/
@@ -163,7 +163,7 @@ ${assetsDir}/
163163
| ├── desktop.vtl # Desktop template
164164
│   └── startup.sh.vtl # Startup script template
165165
├── mac/
166-
| ├── customize-dmg.applescript.vtl # Applescript template
166+
| ├── customize-dmg.applescript.vtl # DMG customization Applescript template
167167
| ├── Info.plist.vtl # Info.plist template
168168
│   └── startup.vtl # Startup script template
169169
├── windows/
@@ -190,28 +190,29 @@ git clone https://github.com/fvarrui/JavaPackager.git
190190
cd JavaPackager
191191
```
192192

193-
2. Compile, package and install the plugin in your local repository:
193+
2. Compile, package and install the plugin in your local repository (ommit `./` on Windows):
194194

195195
```bash
196-
mvn install
196+
./gradlew clean
197+
./gradlew build
198+
./gradlew publishMavenToLocal
197199
```
198200

199201
## How to publish the plugin on Maven Central
200202

201203
```bash
202-
mvn clean release:clean
203-
mvn release:prepare
204-
mvn release:perform
204+
./gradlew -Prelease uploadArchives closeAndPromoteRepository
205205
```
206206

207-
> Related [guide](https://dzone.com/articles/publish-your-artifacts-to-maven-central).
207+
> Related [guide](https://nemerosa.ghost.io/2015/07/01/publishing-to-the-maven-central-using-gradle/).
208208
209209
## Future features
210210

211211
Check the [TO-DO list](https://github.com/fvarrui/JavaPackager/projects/1#column-7704117) to know the features we plan to add to JavaPackager.
212212

213213
## Older documentation
214214

215+
- [v1.0.3](https://github.com/fvarrui/JavaPackager/blob/v1.0.3/README.md)
215216
- [v1.0.2](https://github.com/fvarrui/JavaPackager/blob/v1.0.2/README.md)
216217
- [v1.0.1](https://github.com/fvarrui/JavaPackager/blob/v1.0.1/README.md)
217218
- [v1.0.0](https://github.com/fvarrui/JavaPackager/blob/v1.0.0/README.md)

build.gradle

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
dependencies {
6+
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3"
7+
}
8+
}
9+
10+
plugins {
11+
id 'java'
12+
id 'maven'
13+
id 'maven-publish'
14+
}
15+
16+
repositories {
17+
mavenLocal()
18+
maven {
19+
url = uri('https://repo.maven.apache.org/maven2')
20+
}
21+
}
22+
23+
configurations {
24+
mavenEmbedder
25+
}
26+
27+
dependencies {
28+
implementation 'org.apache.maven:maven-plugin-api:3.6.0'
29+
implementation 'org.codehaus.plexus:plexus-utils:3.1.1'
30+
implementation 'org.twdata.maven:mojo-executor:2.3.0'
31+
implementation 'org.apache.commons:commons-lang3:3.9'
32+
implementation 'commons-io:commons-io:2.6'
33+
implementation 'org.apache.commons:commons-collections4:4.1'
34+
implementation 'org.apache.velocity:velocity-engine-core:2.0'
35+
36+
testImplementation 'junit:junit:4.12'
37+
38+
compileOnly 'org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0'
39+
40+
mavenEmbedder 'org.apache.maven:maven-embedder:3.6.3'
41+
mavenEmbedder 'org.apache.maven:maven-compat:3.6.3'
42+
mavenEmbedder 'org.slf4j:slf4j-simple:1.7.5'
43+
}
44+
45+
group = 'io.github.fvarrui'
46+
version = '1.1.1-SNAPSHOT'
47+
description = 'JavaPackager Plugin'
48+
sourceCompatibility = '1.8'
49+
50+
publishing {
51+
publications {
52+
maven(MavenPublication) {
53+
from(components.java)
54+
}
55+
}
56+
}
57+
58+
tasks.withType(JavaCompile) {
59+
options.encoding = 'UTF-8'
60+
}
61+
62+
install.repositories.mavenInstaller.pom.with {
63+
groupId = project.group
64+
artifactId = project.name
65+
version = project.version
66+
packaging = 'maven-plugin'
67+
}
68+
69+
// runs the plugin description generator
70+
task generatePluginDescriptor(type: JavaExec, dependsOn: compileJava) {
71+
def pomFile = file("$buildDir/pom.xml")
72+
def pluginDescriptorFile = new File(project.compileJava.destinationDir, 'META-INF/maven/plugin.xml')
73+
def directory = buildDir.canonicalPath
74+
def outputDirectory = compileJava.destinationDir.canonicalPath
75+
76+
// FIXME: this does not seem to be working
77+
inputs.files project.compileJava.outputs.files
78+
outputs.file pluginDescriptorFile
79+
80+
classpath = configurations.mavenEmbedder
81+
main = 'org.apache.maven.cli.MavenCli'
82+
systemProperties['maven.multiModuleProjectDirectory'] = projectDir
83+
args = [
84+
'--errors',
85+
'--batch-mode',
86+
'--file', "${buildDir}/pom.xml",
87+
'org.apache.maven.plugins:maven-plugin-plugin:3.4:descriptor'
88+
]
89+
90+
doFirst {
91+
install.repositories
92+
.mavenInstaller
93+
.pom
94+
.withXml {
95+
asNode().appendNode('build')
96+
.with {
97+
appendNode('directory', directory)
98+
appendNode('outputDirectory', outputDirectory)
99+
}
100+
}
101+
.writeTo(pomFile)
102+
103+
assert pomFile.file, "${pomFile.canonicalPath}: was not generated"
104+
logger.info("POM is generated in ${pomFile.canonicalPath}")
105+
}
106+
107+
doLast {
108+
assert pluginDescriptorFile.file, "${pluginDescriptorFile.canonicalPath}: was not generated"
109+
logger.info("Plugin descriptor is generated in ${pluginDescriptorFile.canonicalPath}")
110+
}
111+
}
112+
113+
project.jar.dependsOn(generatePluginDescriptor)
114+
115+
apply plugin: 'io.codearte.nexus-staging'
116+
117+
if (project.hasProperty('release')) {
118+
119+
task javadocJar(type: Jar) {
120+
classifier = 'javadoc'
121+
from javadoc
122+
}
123+
124+
task sourcesJar(type: Jar) {
125+
classifier = 'sources'
126+
from sourceSets.main.allSource
127+
}
128+
129+
artifacts {
130+
archives javadocJar, sourcesJar
131+
}
132+
133+
allprojects {
134+
apply plugin: 'signing'
135+
apply plugin: 'maven'
136+
137+
// Signature of artifacts
138+
signing {
139+
sign configurations.archives
140+
}
141+
142+
// OSSRH publication
143+
uploadArchives {
144+
repositories {
145+
mavenDeployer {
146+
// POM signature
147+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
148+
// Target repository
149+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
150+
authentication(userName: ossrhUser, password: ossrhPassword)
151+
}
152+
pom.project {
153+
name project.name
154+
description project.description
155+
packaging 'jar'
156+
url 'https://github.com/fvarrui/JavaPackager'
157+
158+
scm {
159+
connection 'scm:git:git://github.com/fvarrui/JavaPackager.git'
160+
developerConnection 'scm:git:[email protected]:fvarrui/fvarrui.git'
161+
url 'https://github.com/fvarrui/JavaPackager'
162+
}
163+
164+
licenses {
165+
license {
166+
name 'GPL-v3.0'
167+
url 'http://www.gnu.org/licenses/gpl-3.0.txt'
168+
distribution 'repo'
169+
}
170+
}
171+
172+
developers {
173+
developer {
174+
id = 'fvarrui'
175+
name = 'Francisco Vargas Ruiz'
176+
url = 'https://github.com/fvarrui'
177+
}
178+
}
179+
}
180+
}
181+
}
182+
}
183+
184+
}
185+
}
186+
187+
nexusStaging {
188+
username = ossrhUser
189+
password = ossrhPassword
190+
}

0 commit comments

Comments
 (0)