I cannot see the generated Java code
vahdat-ab opened this issue · 15 comments
I have the following script
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath "gradle.plugin.cruise.umple:UmpleGradlePlugin:0.1.0"
classpath files('/libs/umple.jar')
classpath 'de.undercouch:gradle-download-task:3.1.2'
}
}
apply plugin: 'de.undercouch.download'
apply plugin: 'umple.gradle.plugin'
download {
onlyIfNewer = true
overwrite = true
src 'http://cruise.eecs.uottawa.ca/umpleonline/scripts/umple.jar'
dest '/libs/'
}
I build and no issue at all.
I have an Umple file called test.ump with the following content:
class X{
void test(){
}
}
When I execute the following command
gradle compileUmpleFile -PumpleFileName=test.ump -PlanguageToGenerate=Java
it shows the following message:
:compileUmpleFile
Processing -> test.ump
Success! Processed test.ump.
BUILD SUCCESSFUL
Total time: 3.101 secs
Where is the Java file X.java
now? I couldn't file it.
@ahochheiden
If you don't set the outputPath, it should just create a folder in the directory of your Gradle build script called umpleOutput, which will contain all the code generated by Umple.
My build.gradle:
buildscript {
repositories {
maven {
url uri('../umple.gradle/libs/')
}
jcenter()
}
dependencies {
classpath files('../umple.gradle/libs/umple-latest.jar')
classpath group: 'cruise.umple', name: 'UmpleGradlePlugin', version: '0.1.0'
classpath 'de.undercouch:gradle-download-task:3.1.2'
}
}
apply plugin: 'de.undercouch.download'
apply plugin: 'umple.gradle.plugin'
download {
onlyIfNewer = true
overwrite = true
src 'http://cruise.eecs.uottawa.ca/umpleonline/scripts/umple.jar'
dest '../umple.gradle/libs/umple-latest.jar'
}
My test.ump:
// Airline system - sample UML class diagram in Umple
// From Book by Lethbridge and Laganiere, McGraw Hill 2004
// Object-Oriented Software Engineering: Practical Software Engineering using UML and Java
// See http://www.lloseng.com
namespace Airline;
class Airline{
1 -- * RegularFlight;
1 -- * Person;
}
class RegularFlight{
Time time;
unique Integer flightNumber;
1 -- * SpecificFlight;
}
class SpecificFlight{
unique Date date;
}
class PassengerRole
{
isA PersonRole;
immutable String name ;
1 -- * Booking;
}
class EmployeeRole
{
String jobFunction ;
isA PersonRole;
* -- 0..1 EmployeeRole supervisor;
* -- * SpecificFlight;
}
class Person
{
settable String name;
Integer idNumber;
1 -- 0..2 PersonRole;
}
class PersonRole{}
class Booking{
String seatNumber;
* -- 1 SpecificFlight;
}
about:blank
Step 2:
C:\Users\Alex Hochheiden\Documents\GitHub\test>gradle compileUmpleFile -PumpleFileName=test.ump -PlanguageToGenerate=Java
:compileUmpleFile
Processing -> test.ump
Success! Processed test.ump.
BUILD SUCCESSFUL
Total time: 1.334 secs
Step 3:
After calling Umple through gradle via gradle compileUmpleFile -PumpleFileName=test.ump -PlanguageToGenerate=Java
Let me know if you're still having issue .
E: @Nava2 - changed the images to be an inline image rather than link
I have the following settings:
c:\umple.gradle
c:\test
Gradle's version is 3.1
I have exactly the above build script and umple file inside the test
folder and when run your script it gives the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'test'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find cruise.umple:UmpleGradlePlugin:0.1.0.
Searched in the following locations:
file:/C:/umple.gradle/libs/cruise/umple/UmpleGradlePlugin/0.1.0/UmpleGradlePlugin-0.1.0.pom
file:/C:/umple.gradle/libs/cruise/umple/UmpleGradlePlugin/0.1.0/UmpleGradlePlugin-0.1.0.jar
https://jcenter.bintray.com/cruise/umple/UmpleGradlePlugin/0.1.0/UmpleGradlePlugin-0.1.0.pom
https://jcenter.bintray.com/cruise/umple/UmpleGradlePlugin/0.1.0/UmpleGradlePlugin-0.1.0.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.885 secs
what I miss? can it be because of the difference in the versions?
Now, it works based on the recent update on the plugin
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath "gradle.plugin.cruise.umple:UmpleGradlePlugin:0.1.1"
classpath files('/libs/umple.jar')
classpath 'de.undercouch:gradle-download-task:3.1.2'
}
}
apply plugin: 'de.undercouch.download'
apply plugin: "umple.gradle.plugin"
download {
onlyIfNewer = true
overwrite = true
src 'http://cruise.eecs.uottawa.ca/umpleonline/scripts/umple.jar'
dest '/libs/'
}
However, I couldn't run it through the local addressing. curious why :-) ?
Another thing that I noticed is that I cannot build if umple.jar is not there. It is supposed to be downloaded automatically when it's the fist time. If I build for the first time, I get the following error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\umple.gradle\test\build.gradle' line: 17
* What went wrong:
A problem occurred evaluating root project 'test'.
> Failed to apply plugin [id 'umple.gradle.plugin']
> Could not create plugin of type 'UmpleGradlePlugin'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.165 secs
The way I solve it is to comment the following line
//apply plugin: "umple.gradle.plugin"
It downloads the umple.jar and then I uncomment apply plugin: "umple.gradle.plugin"
. After that it works perfectly
Now, it works based on the recent update on the plugin
Yeah, I realized the most recently published version didn't match master early this morning. I got the API keys from Tim and published master after changing to version 0.1.1. I think that was the problem, since my scripts were working fine with my locally built version.
However, I couldn't run it through the local addressing. curious why :-) ?
I'm not sure what you mean by this.
Another thing that I noticed is that I cannot build if umple.jar is not there. It is supposed to be downloaded automatically when it's the fist time. If I build for the first time, I get the following error:
I never noticed this. My manual test strategy always involved building the plugin from scratch then running my sample test script that uses the gradle plugin. The build script for the plugin had already downloaded the umple jar, so I never caught this.
However, it looks like the fix is simple. Just put the download between the two apply plugins.
Example:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath "gradle.plugin.cruise.umple:UmpleGradlePlugin:0.1.1"
classpath files('/libs/umple.jar')
classpath 'de.undercouch:gradle-download-task:3.1.2'
}
}
apply plugin: 'de.undercouch.download'
download {
onlyIfNewer = true
overwrite = true
src 'http://cruise.eecs.uottawa.ca/umpleonline/scripts/umple.jar'
dest '/libs/'
}
apply plugin: "umple.gradle.plugin"
Let me know if that works.
Edit: Actually, this doesn't quite work. It does download the umple jar before attempting to apply the plugin, but the apply still fails for some reason. If you run the same script a second time it works.
ie:
gradle compileUmpleFile -PumpleFileName=test.ump -PlanguageToGenerate=Java
- fail
gradle compileUmpleFile -PumpleFileName=test.ump -PlanguageToGenerate=Java
pass
or
gradle build
- pass
gradle compileUmpleFile -PumpleFileName=test.ump -PlanguageToGenerate=Java
- pass
I'm in the habit of typing gradle build
before I do anything else, so that's sort of skewing my results. I'll see if I can come up with a better solution.
Ideally the compileUmpleFile task would depend on a download task in the plugin, that way the end user would never have to take care of adding the download task, the plugin would do it automatically. I'm not sure if that's possible though, since the end user still has to specify the location for the umple jar dependency in their build script. Seems like a chicken or the egg problem.
Yes, you need to run it two times gradle build
.
I'm still having issues related to running the script when I point it to a local reporsitory.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'test'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find cruise.umple:UmpleGradlePlugin:0.1.0.
Searched in the following locations:
file:/C:/umple.gradle/libs/cruise/umple/UmpleGradlePlugin/0.1.0/UmpleGradlePlugin-0.1.0.pom
file:/C:/umple.gradle/libs/cruise/umple/UmpleGradlePlugin/0.1.0/UmpleGradlePlugin-0.1.0.jar
https://jcenter.bintray.com/cruise/umple/UmpleGradlePlugin/0.1.0/UmpleGradlePlugin-0.1.0.pom
https://jcenter.bintray.com/cruise/umple/UmpleGradlePlugin/0.1.0/UmpleGradlePlugin-0.1.0.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.885 secs
What does your current build script look like?
buildscript {
repositories {
maven {
url uri('../umple.gradle/libs/')
}
jcenter()
}
dependencies {
classpath files('../umple.gradle/libs/umple-latest.jar')
classpath group: 'cruise.umple', name: 'UmpleGradlePlugin', version: '0.1.1'
classpath 'de.undercouch:gradle-download-task:3.1.2'
}
}
apply plugin: 'de.undercouch.download'
apply plugin: 'umple.gradle.plugin'
download {
onlyIfNewer = true
overwrite = true
src 'http://cruise.eecs.uottawa.ca/umpleonline/scripts/umple.jar'
dest '../umple.gradle/libs/umple-latest.jar'
}
I even run it with 0.1.0
So you're building the gradle plugin locally and expecting it to be in /umple.gradle/libs/
, correct?
What command are you using to build it?
gradle uploadArchives
puts it in /umple.gradle/libs/
by default. I was using that to move it up and out to a relative nested path, since I hadn't gotten the local maven repository working.
If you don't use uploadArchives, and build with gradle build
, it'll be in /umple.gradle/build/libs/
, but it won't be in the same classpath structure that your buildscript expects.
If you have any recommendations for setting up a real local maven repository that'd be great. It seemed as though there was a maven dependency when I played around with it, and that there was an environment variable required.
Just chiming in because I got all of these emails:
Yeah, I realized the most recently published version didn't match master early this morning. I got the API keys from Tim and published master after changing to version 0.1.1.
Do we have Umple hosted in Maven now? Or is this referring to the gradle plugin repository?
If you don't use uploadArchives, and build with gradle build, it'll be in /umple.gradle/build/libs/, but it won't be in the same classpath structure that your buildscript expects.
This is expected, it's gradle convention to put built artifacts in /libs
. uploadArchives
should work out of the box.
If you have any recommendations for setting up a real local maven repository that'd be great. It seemed as though there was a maven dependency when I played around with it, and that there was an environment variable required.
Your maven repository should already be present, it's in ~/.m2
, typically.
(sorry the image is massive..)
All of this is really indicates why we need tests. Functional tests that run through flows that an expected user would go through. These flows also allow a user to look at the examples and figure out how to get what they need done, done.
I don't know why this is the case, I need to run two times gradle uploadArchives
to make it workin.
In order to run my script, It needs to run two times gradle uploadArchives
in umple.gradle
folder and then the script inside test
will be executed.
I wonder you can explore this two times execution for both plugin and test? Plugin works but it's not straightforward to use it
Do we have Umple hosted in Maven now? Or is this referring to the gradle plugin repository?
https://plugins.gradle.org/plugin/umple.gradle.plugin
This is expected, it's gradle convention to put built artifacts in /libs. uploadArchives should work out of the box.
Yeah, I wasn't saying there was anything wrong with this, just pointing out to Vahdat how it was working. You mentioning that uploadArchives is baseline helped though. I had uploadArchives explicitly defined, which overrides the default behavior. Removing it makes it publish to the mavenLocal repository.
This sort of ties back to the original problem I had though. I was trying to explicitly state the mavenLocal directory. Calling mavenLocal() does not seem to work.
download {
onlyIfNewer = true
overwrite = true
src 'http://cruise.eecs.uottawa.ca/umpleonline/scripts/umple.jar'
dest mavenLocal()
}
I want the download task to put the umple jar in the mavenLocal repository, how do I specify it?
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri('libs/'))
}
}
}
Was where I wanted to specify it originally, but it wasn't working either, same issue as the download task. Which is what I brought up environment variables, which do not seem like a good solution. I feel like there's a simple way to specify it, I just don't know it.
Ideally what I'd like is to be able to get the directory and concatenate it with my desired name for the umple jar.
eg:
mavenLocal() + "/umple-latest.jar"
All of this is really indicates why we need tests. Functional tests that run through flows that an expected user would go through. These flows also allow a user to look at the examples and figure out how to get what they need done, done.
I'm working on it.
I don't know why this is the case, I need to run two times gradle uploadArchives to make it workin.
In order to run my script, It needs to run two times gradle uploadArchives in umple.gradle folder and then the script inside test will be executed.
I wonder you can explore this two times execution for both plugin and test? Plugin works but it's not straightforward to use it
This doesn't match my experience. Here's what works for me:
- In /umple.gradle
gradle uploadArchives
// plugin is built and pushed to /libs - In /test 'gradle build' // download for umple jar is triggered
- In /test 'gradle compileUmpleFile -PumpleFileName=test.ump -PlanguageToGenerate=Java' // test.ump passed to umple.jar through gradle, compiles successfully.
The build before the 'compileUmpleFile' seems to be necessary due to the dependency block in the buildscript block. It depends on the umple jar, but it didn't exist when it was executed. We can't put the download before since it has a classpath dependency too. Which leads us to the chicken or the egg problem I was talking about.
I found a way to make it work, but it seems really 'stupid', and goes against how I think about the mavenLocal directory.
Basically, I hard-coded it to the default path. To me the idea of mavenLocal is that it's a potentially dynamically located directory based on your maven settings. Hard coding it to the default just seems wrong, even if it works.
@vahdat-ab Can I close this issue? The plugin is so different than it was in December I'm not sure it still applies.
Yes. This issue is closed because the plugin has been changed a lot and it is not valid anymore.