How to run try.freemarker.apache.org locally [closed] - freemarker

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
https://try.freemarker.apache.org/ is down, or more likely, it's not publicly available anymore as I'm getting ERR_CONNECTION_REFUSED. It's been such a great tool to quickly check syntax as I often send FreeMarker snippets to others.
Is it possible to run this site locally?

Update (2021-05-05): Site is up: https://try.freemarker.apache.org/
I found the source code on github along with build and deploy instructions:
https://github.com/apache/freemarker-online-tester
You can follow the instructions (requires Java 1.8) to get this tool running locally on your machine and never deal with availability issue again!. I tested it:
Steps
Clone the repository https://github.com/apache/freemarker-online-tester.git
Open cmd in project folder root and run command: gradlew build
Wait until gradle wrapper installs gradle and all dependencies then builds, here's the expected output:
:compileJava
:processResources
:classes
:jar
:assemble
:compileTestJava
Download https://repo1.maven.org/maven2/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.pom
:processTestResources
:testClasses
:test
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.7.8/org.jacoco.agent-0.7.8.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.build/0.7.8/org.jacoco.build-0.7.8.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.7.8/org.jacoco.agent-0.7.8.jar
:jacocoTestReport
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.ant/0.7.8/org.jacoco.ant-0.7.8.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.core/0.7.8/org.jacoco.core-0.7.8.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.report/0.7.8/org.jacoco.report-0.7.8.pom
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-debug-all/5.1/asm-debug-all-5.1.pom
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-parent/5.1/asm-parent-5.1.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.ant/0.7.8/org.jacoco.ant-0.7.8.jar
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.core/0.7.8/org.jacoco.core-0.7.8.jar
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.report/0.7.8/org.jacoco.report-0.7.8.jar
Download https://repo1.maven.org/maven2/org/ow2/asm/asm-debug-all/5.1/asm-debug-all-5.1.jar
:check
:shadowJar
:build
BUILD SUCCESSFUL
Run gradlew shadowJar
Expected output:
$ gradlew shadowJar
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:shadowJar
BUILD SUCCESSFUL
Total time: 2.413 secs
Start the application, run command: java -jar build/libs/freemarker-online-0.1-SNAPSHOT.jar server src/main/resources/freemarker-online.yml
Here is a screenshot from the running server console:
Visit your Online FreeMarker Template Tester's link:
http://localhost:8080/

Related

development CI buidl practice [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am having a dispute will a colleague. We use maven to build our software and we both have a fair amount of experience with it. However something I have never seen done before is to disable maven tests by default with a profile. If the developer wants to skip tests then the -DskipTests option is available. His argument is that: You don't want every CI pipeline to re-run all the previous steps. Well if that is the case then instead of using:
mvn clean install
then use
- mvn clean
- mvn compile test-compile
- mvn test
- mvn verify
- mvn package
However this also is unacceptable. He says at every company he has worked at this is standard. I cannot think of a single project I have looked at in OSS that uses maven that uses the convention of disabling mavens test functionality by default.
Am I confused? The whole selling point is that the build is standard and it requires direct intent to avoid running tests.
You don't skip tests as default.
And you don't let different CI steps repeat the ones before. So don't try to split the Maven build and first run mvn test and then mvn verify and then mvn package because you do a lot of work thrice.
Just use mvn clean deploy and you'll be fine.

How do I force Gradle to get the most recent snapshot version of my package?

I have a Maven package I've hosted on GitHub package registry.
Whenever I make an update to the package I run mvn deploy to publish the changes, but if I simply run gradle install on the dependent application it doesn't seem to install the latest version of the package
(not sure if settings.xml is relevant to this question so I removed it, but it can be seen at the link to my previous question).
I had a similar issue with using the latest snapshot version of the package in another dependent, which was using Maven as the package manager/build tool instead of Gradle. That was resolved by checking a box to "always update snapshots" in Maven settings. I have checked the box in this project as well, but it doesn't seem to resolve the issue now.
What I have tried:
Invalidating cache and restarting IntelliJ
reimporting all gradle projects
deleting the dependency from my build.gradle and then reimporting projects and install, followed by adding it back and reimporting all projects and install
running ./gradlew build -x test --refresh-dependencies (test disabled because they were failing)
This is the log after I run gradle install:
4:07:08 PM: Executing task 'install'...
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jar SKIPPED
> Task :install
BUILD SUCCESSFUL in 2s
3 actionable tasks: 1 executed, 2 up-to-date
4:07:10 PM: Task execution finished 'install'.
In my build.gradle I use the following syntax for my dependency (under dependencies):
compile('com.companyname:packagename:0.0.3-SNAPSHOT')
and this is what I have under repositories:
maven {
url "https://maven.pkg.github.com/companyname/packagename"
credentials {
username "TaylorBurke"
password "*****************"
}
}
Not sure if it is related, but when I go into my Maven settings to try and update the repository I get this error:
So there it is, I think I've included everything. Is it a configuration issue with Maven, Gradle, or IntelliJ?
Edit: because it has been suggested to close this question I am pointing out that the link to the other question does not address installing with Gradle, it simply addresses an error after running mvn deploy. I have already deployed the new package successfully and can get the new version from my other application. My problem is specific to gradle install. Even though the accepted answer mentions he had a similar problem using Gradle (but my problem is not with deploying either) he goes on to say that snapshot versions would provide a solution to the problem expressed, and I am already using a snapshot version in this package. That question is clearly quite different and not at all related to mine.
You have tried quite a few things with IntelliJ, but the problem happens when you run the build from the command line (./gradlew build). That should be a good indication that the problem is not with IntelliJ.
By default, Gradle will cache changing dependencies (e.g. SNAPHOST dependencies) for 24 hours. During that time, it will not ask the repository for newer versions. So if you publish a new version under the same name, Gradle might not see it for another day.
Using the --refresh-dependencies option will make Gradle ignore the cache, and thereby download the artifacts again.
You can also change the cache retention period through a ResolutionStrategy. You can also configure it to always check for changed dependencies if you like.
Read more about dynamic dependencies here: https://docs.gradle.org/current/userguide/dynamic_versions.html
If you are curious, the Gradle artifact cache is by default located in $USER_HOME/.gradle/caches/modules-2/files-2.1 (the numbers may be different depending on which version of Gradle you are using). This cache is unrelated to the one you mention in IntelliJ.
Also, the authentication error in the IntelliJ maven repository browser is because your credentials are in the Gradle configuration and not in IntelliJ. So this is also unrelated to Gradle.

Gradle Multiproject with SCM

I am migrating to Gradle as my build tool for a Java project.
My main project (A) has a dependency on other projects (B and C).
At the moment each of these projects are in CVS individually and when I want to compile A I have to check out A, make a subdir in A called B in which I check out B. Same goes for C.
Im going to migrate to repository manager (nexus) in which B and C can be published to. When this happens, module A can just have a dependency on B and C which it can get from nexus.
However, the difficulty arises if I do not want to publish B and C (for testing purposes) and I want to build A with my latest code from B and C without committing it to nexus.
My initial thoughts on this are to build the jar for B and C and pull it into the "lib" folder for A. However Im sure there is a better way.
In maven I could do a "mvn clean install" which would install B and C in my local maven cache. A would then look there for the appropriate jars.
But Im still not sure this is the best way. I had a look into gradle subprojects but I dont fully understand them. How would the submodules handle in an SCM (would I also need to use git submodules?)
I would appreciate some guidance as to best practices for this situation.
Thanks
EDIT:
The reply below from Vyacheslav Shvets is the most accurate answer I have found so far.
There is one other way of switching out a gradle project dependency with maven-style dependency. This involves dependency substitution as described at https://docs.gradle.org/current/userguide/dependency_management.html#sec:project_to_module_substitution
This can be wrapped around a:
if(project.hasProperty("someSwitch")){
configurations.all{.....
....
}
}
Usage of this method would be:
gradle build -Psomeswitch
The old (classical) way
The same approach as for Maven:
Apply maven plugin on project B
Run gradle clean install on project B
Actually, you don't have to clean every time if your build correctly uses task inputs and outputs
In project A, add mavenLocal() repository and run build
The new way (experemental) - Composite build
A composite build allows you to combine multiple Gradle builds and replace external binary dependencies with project dependencies as if you were using a single multi-project build
https://docs.gradle.org/2.13/release-notes
This is not fully available yet. Since 2.13 you can use it via Tooling API (for example, Buildship 2.0 plugin for Eclipse IDE). The common usage will be available in 3.1, but you can try it now using nightly builds of 3.1
If you download and execute demo build from Gradle's github with latest nightly build you will see the following:
$ gradle build
[composite-build] Configuring build: C:\Users\Shvets\repos\composite\projectB
[composite-build] Configuring build: C:\Users\Shvets\repos\composite\projectC
:compileJava
:projectB:b1:compileJava
:projectB:b1:processResources UP-TO-DATE
:projectB:b1:classes
:projectB:b1:jar
:projectB:b2:compileJava
:projectC:compileJava
:projectC:processResources UP-TO-DATE
:projectC:classes
:projectC:jar
:projectB:b2:processResources UP-TO-DATE
:projectB:b2:classes
:projectB:b2:jar
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
BUILD SUCCESSFUL
Total time: 4.497 secs
For deep understanding, see demo video of both approaches.

Gradle: 'Normal' build vs. analysis build

On my Jenkins (or some other CI server) I want to build the develop branch with full analysis, which includes:
Checkstyle
Emma (coverage for feature-, integration-, and unit-tests)
FindBugs
JSHint
PMD (including CopyPasteDetection)
But at the same time I don't want all this stuff running, when I build locally.
A build on my development PC should only compile and run unit tests.
How does one solve this 'the gradle way'?
You could create an analysis task in your build.gradle that depends on all the analysis tasks you want to run on the CI server. Then in the "Tasks" section of the Jenkins configuration for your build, specify the analysis task instead of build.

GroovyDoc in Gradle not working

I am trying to generate groovydocs in gradle script using command gradle groovydoc. I can see the command executed successfully as below:
Dynamic properties are deprecated: http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:groovydoc UP-TO-DATE
BUILD SUCCESSFUL
But I don't see any API generated in the file system. What am I missing here?
Given the information you provide, it's impossible to say. We'd have to see the build scripts, output of gradle -v, etc. The first line of output indicates that you may have misspelled a configuration property in the build script. Recent versions of Gradle will print the property in question. If you get the UP-TO-DATE even for gradle clean groovydoc, it's a clear sign that something isn't configured correctly.

Resources