my searchversion.exe file is not running in the script..why is that so?
<project name="nightly_build" default="main" basedir="checkout">
<target name="init">
<property file="initial.properties"/>
<property file="C:/Work/lastestbuild.properties"/>
<tstamp>
<format property="suffix" pattern="yyyyMMddHHmmss"/>
</tstamp>
</target>
<target name="main" depends="init">
<sequential>
<exec executable="C:/Work/Searchversion.exe"/>
...
</sequential>
</target>
</project>
Searchversion.exe will generate latestbuild.properties file. I do not have any arguments for Searchversion.exe.
Here is the code for searchversion.exe:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Search
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "sslist.exe";
p.StartInfo.Arguments = "-R -H -h sinsscm01.ds.net /mobile";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start();
string procOutput = p.StandardOutput.ReadToEnd();
string procError = p.StandardError.ReadToEnd();
TextWriter outputlog = new StreamWriter("C:\\Work\\listofsnapshot.txt");
outputlog.Write(procOutput);
outputlog.Close();
string greatestVersionNumber = "";
using (StreamReader sr = new StreamReader("C:\\Work\\listofsnapshot.txt"))
{
while (sr.Peek() >= 0)
{
var line = sr.ReadLine();
var versionNumber = line.Replace(#"6.70_Extensions/6.70.102/ANT_SASE_RELEASE_", "");
if(versionNumber.Length != line.Length)
greatestVersionNumber = versionNumber;
}
}
Console.WriteLine(greatestVersionNumber);
TextWriter latest = new StreamWriter("C:\\Work\\latestbuild.properties");
latest.Write("Version_Number=" + greatestVersionNumber);
latest.Close();
}
}
}
sslist.exe gets a list of snapshots found in my version control software, and i will get the greatest version number and save it as a text (latestbuild.properties)
Two things in your script look odd.
I don't think you need the <sequential> task in the <main> target.
The depends attribute of you <main> target will cause the <init> target to run before Searchversion.exe. So, perhaps it is getting run, just too late.
Assuming #2 is the cause of your problem you should restructure your script to look like this:
<project name="nightly_build" default="main" basedir="checkout">
<target name="init">
<exec executable="C:/Work/Searchversion.exe"/>
<property file="initial.properties"/>
<property file="C:/Work/lastestbuild.properties"/>
<tstamp>
<format property="suffix" pattern="yyyyMMddHHmmss"/>
</tstamp>
</target>
<target name="main" depends="init">
...
</target>
</project>
Related
I am trying to use Mapstruct in my Quarkus project, but when i run the app with /.mvnw compile quarkus:dev
i got the following exception:
javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type
org.acme.dto.mapper.BookMapper and qualifiers [#Default]
(I have checked the generated classes in target/generated-sources, and they get #ApplicationScoped)
Details:
Mapstruct dependencies are added to the pom.xml as:
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
<scope>provided</scope>
</dependency>
Than i have several mappers like:
#Mapper(componentModel = "cdi", uses = { BookDetailsMapper.class, AuthorMapper.class })
public interface BookMapper {
BookDto toDto(Book book);
Book toEntity(BookDto bookDto);
}
#Mapper(componentModel = "cdi")
public interface AuthorMapper {
AuthorDto toDto(Author author);
Author toEntity(AuthorDto author);
}
#Mapper(componentModel = "cdi")
public interface BookDetailsMapper {
BookDetailsDto toDto(BookDetails bookDetails);
BookDetails toEntity(BookDetailsDto bookDetailsDto);
}
And the BookMapper bean is injected in:
#ApplicationScoped
public class BookService {
private final BookMapper bookMapper;
#Inject
public BookService(BookMapper bookMapper) {
this.bookMapper = bookMapper;
}
...
The problem was that generated-sources of mapstruct was not compiled to class files.
I had to add the mapstruct-processor dependency as follows:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.platform.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
In short I am not able to make a computation based on a property within my build file.
Let's say I have:
<property name="basedir" value="${project.basedir}" /> <--Current value 73
How can I know the previous 3 builds (72,71 and 70) OR how can I compute these values(based on the basedir property)?
I have tried (ignore the addition):
<property name="basedir" value="${project.basedir}+1" /> <--But it concats the value: 73+1
<property name="basedir" value="${project.basedir+1}" /> <--But it is just wrong: build_${env.BUILD_NUMBER+1}
Scenario: Remove old releases (keep some releases in case of a rollback)
P.S: The duplicate link is invalid because this is a deployment via PHING not ANT
You could use an adhoc-task for this:
<?xml version="1.0"?>
<project default="main" phingVersion="2.11.0">
<property name="basedir" value = "73"/>
<adhoc-task name="increment"><![CDATA[
class increment extends Task {
private $value;
function setvalue($value) {
$this->value = $value;
}
function setProperty($property) {
$this->property = $property;
}
function main() {
$this->project->setProperty($this->property, ((int) $this->value + 1));
}
}
]]></adhoc-task>
<target name="main">
<echo>${basedir}</echo>
<increment value="${basedir}" property="basedir"/>
<echo>${basedir}</echo>
</target>
</project>
I would like to know how to pass groovy script variables(here: compName, compPath) to the ant target (here : build.application)
I would like to make the values of compName and compPath available to all ant targets in this build.xml
<target name="xmlreader" description="Clean deployment directory">
<groovy>
import javax.xml.xpath.*
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
def ant = new AntBuilder()
File buildfile = new File("d:/Users/sk/workspace/build.xml")
fileContent = buildfile.getText()
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(buildfile);
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr = xpath.compile("BuildConfig/Applications/ApplicationConfig");
NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int i = 0; i < nl.getLength() ; i++) {
String compName = (String)nl.item(i).getElementsByTagName("Name").item(0).getChildNodes().item(0).getNodeValue();
String compPath = (String)nl.item(i).getElementsByTagName("SVN_Path").item(0).getChildNodes().item(0).getNodeValue();
ant.echo "${compName}"
ant.echo "${compPath}"
ant.ant( antfile: 'build.xml' ){
target(name: 'build.application')
}
}
</groovy>
</target>
To answer your direct question, the ant task accepts property children to set properties in the new project used by the target you're calling:
ant.ant( antfile: 'build.xml', target: 'build.application') {
property(name:'compName', value:compName)
property(name:'compPath', value:compPath)
}
But you could also consider xmltask, whose "call" function can achieve the same thing without all the Groovy code.
<xmltask source="d:/Users/sk/workspace/build.xml">
<call path="BuildConfig/Applications/ApplicationConfig" target="build.application">
<param name="compName" path="Name" />
<param name="compPath" path="SVN_Path" />
</call>
</xmltask>
I get the following error trying to run my application
fatal error: use of unimplemented initializer 'init(entity:insertIntoManagedObjectContext:)' for class 'rcresttest.CatalogItem'
I can bypass this error by changing the Entity's class in the data model to something else, but then I will get a swift_dynamicCastClassUnconditional: when trying to downcast.
Is this a bug in beta6 or am I doing something wrong?
CatalogItem.swift
import CoreData
#objc(CatalogItem)
class CatalogItem : NSManagedObject {
#NSManaged var id : String
#NSManaged var slug : String
#NSManaged var catalogItemId : String
init(entity: NSEntityDescription!, context: NSManagedObjectContext!, catalogResultsDict : NSDictionary) {
super.init(entity: entity, insertIntoManagedObjectContext: context)
id = catalogResultsDict["Id"] as String
slug = catalogResultsDict["Slug"] as String
catalogItemId = catalogResultsDict["CatalogItemId"] as String
}
}
and the data model
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="6220.8" systemVersion="13E28" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
<entity name="CatalogItem" representedClassName="CatalogItem" syncable="YES">
<attribute name="catalogItemId" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="id" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="slug" optional="YES" attributeType="String" syncable="YES"/>
</entity>
<elements>
<element name="CatalogItem" positionX="-45" positionY="0" width="128" height="90"/>
</elements>
</model>
Edit:
After changing the name of the datamodel class to have the module prefix The error message appears after trying to cast.
2014-08-20 10:49:15.335 rcresttest[63516:4194127] CoreData: warning: Unable to load class named 'rcresttest.CatalogItem' for entity 'CatalogItem'. Class not found, using default NSManagedObject instead.
This is a problem with the designated initializer. Just add convenience in front of your init and call init(entity:insertIntoManagedObjectContext:) on self instead super.
I am trying to execute following code but I am getting null pointer exception.
<property name="from" value="from"/>
<property name="to" value="to"/>
<taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpath="G:\Tibco_Training\groovy-binary-1.8.5\groovy-all-1.6.5.jar" />
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<groovy>
class MoveDir extends org.apache.tools.ant.Task {
//def from = 'from'
//def to = 'to'
public void execute() {
new File(properties.from).eachFileMatch ~/.*/, { file ->
file.renameTo(new File(properties.to , file.getName()))
println "Moving file: $file.name from: " + from + " to: " + to }
}
}
project.addTaskDefinition('movedir', MoveDir)
</groovy>
<movedir />
If I don't use ant properties in groovy then the code works fine, but when I use ant properties for specifying directories, then it give null pointer exception. Am I passing wrong values or wrong syntax is the cause.
Wrong syntax, you have to use properties.'to' and properties.'from'